From patchwork Fri May 26 04:07:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 767220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wYt0F40Kyz9s2s for ; Fri, 26 May 2017 14:08:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="loBvfUR5"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wYt0F30gVzDqNb for ; Fri, 26 May 2017 14:08:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="loBvfUR5"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wYt053MsnzDqNL for ; Fri, 26 May 2017 14:08:04 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="loBvfUR5"; dkim-atps=neutral Received: by mail-pf0-x241.google.com with SMTP id f27so43224182pfe.0 for ; Thu, 25 May 2017 21:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=FlkzNhwq4sbnQ4hcyxu7T/kr7MhzlBs6zYGvmBKJ7f8=; b=loBvfUR5WZU9meJ38zjG1w7oATtynl0fzwhIXGvS7kDwoD3vLV/FZW4ut+XkrneXiQ A1S5dra76Tc8XWjFf4uZNAHxdDceKKFUBFY2nUq40s5Cj9fxDH5qMi+PboBAsojZFndG iTDZfBpIcL4uFCegV/l5LA1akvzMp1OhBB4+odXkc8E+LKnNks4UKwLKV72eaSMOajPQ 6BR2KiUl61+S92+LO/RXi0PIa8w/tbATVOb03Eopf2Zyxwg4rRRYrlqeo+7iBnfSSu5+ Z4/XbqvYCEQBpubYti64SajHT4iHw4jPYOmALaeWNbTUXyyo+tuXFn78F1YGzHYNkdon Fstw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FlkzNhwq4sbnQ4hcyxu7T/kr7MhzlBs6zYGvmBKJ7f8=; b=Ih5SQldf4sPTTZP0Jh32y6Pr6hbU7Wgz2OHRkMC521Zw1ar6sb3zI1Ti28NTEVdbt4 IAWKcgYpw96vBxwL0XwaAQ5FZUVYEl1Z1tTxhau1yuCSZgs+md1qvlAFbe7ukd+0LJ+3 mdUY2lgfQVDsh5xeBYmaNGXJXF+IkuFgAMk1WS64tQR7G9AjZDmYqGUfdZdIUjqRfVdI X2fGkqBzrHzwTUf3kWbZyVgkK/6n6U7JdOjB/8brG0XMZat7cOiYw9MawPQQ0iQRbuCe XbTOcju/WChBN40UDg2RIcAvoeYbsFyQ6dmoD/2xNWjrizJzCCtb/UUMMTmrep7ewVwv abVQ== X-Gm-Message-State: AODbwcBI4sx02S0zfP9Rm4+hLUU56OJClgX/0DnDhsuEyUXfO1zWin5g RzUh4JosjO+jJw== X-Received: by 10.99.39.194 with SMTP id n185mr50271007pgn.15.1495771682945; Thu, 25 May 2017 21:08:02 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id l186sm15007715pgd.42.2017.05.25.21.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 May 2017 21:08:02 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Fri, 26 May 2017 14:07:48 +1000 Message-Id: <20170526040748.10540-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [Skiboot] [PATCH] libflash: Initialise entries list earlier X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aneesh.kumar@linux.vnet.ibm.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" In the bail-out path we call ffs_close() to tear down the partially initialised ffs_handle. ffs_close() expects the entries list to be initialised so we need to do that earlier to prevent a null pointer dereference. Signed-off-by: Oliver O'Halloran --- libflash/libffs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libflash/libffs.c b/libflash/libffs.c index dca40188edb8..763e061c7a19 100644 --- a/libflash/libffs.c +++ b/libflash/libffs.c @@ -256,6 +256,7 @@ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl, f->toc_offset = offset; f->max_size = max_size; f->bl = bl; + list_head_init(&f->hdr.entries); /* Convert and check flash header */ rc = ffs_check_convert_header(&f->hdr, &raw_hdr); @@ -298,7 +299,6 @@ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl, goto out; } - list_head_init(&f->hdr.entries); for (i = 0; i < be32_to_cpu(raw_hdr.entry_count); i++) { struct ffs_entry *ent = calloc(1, sizeof(struct ffs_entry)); if (!ent) {