From patchwork Tue Aug 29 06:24:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 806978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xhJyB6JHHz9ryr for ; Tue, 29 Aug 2017 16:44:02 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xhJyB5SGtzDql8 for ; Tue, 29 Aug 2017 16:44:02 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xhJZW1L6vzDqYN for ; Tue, 29 Aug 2017 16:26:59 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T6OCSe118678 for ; Tue, 29 Aug 2017 02:26:56 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmur5h2g8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 29 Aug 2017 02:26:56 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 29 Aug 2017 16:26:53 +1000 Received: from d23relay07.au.ibm.com (202.81.31.226) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 29 Aug 2017 16:26:51 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T6PaCP36241552 for ; Tue, 29 Aug 2017 16:25:36 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v7T6Pav3017742 for ; Tue, 29 Aug 2017 16:25:36 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v7T6Patt017733; Tue, 29 Aug 2017 16:25:36 +1000 Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 4257CA0273; Tue, 29 Aug 2017 16:25:35 +1000 (AEST) From: Cyril Bur To: skiboot@lists.ozlabs.org, stewart@linux.vnet.ibm.com Date: Tue, 29 Aug 2017 16:24:58 +1000 X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170829062506.8317-1-cyril.bur@au1.ibm.com> References: <20170829062506.8317-1-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable x-cbid: 17082906-0040-0000-0000-00000351E32D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082906-0041-0000-0000-00000CCFDD9E Message-Id: <20170829062506.8317-6-cyril.bur@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-29_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290096 Subject: [Skiboot] [RFC PATCH 05/13] libflash/libffs: ffs_close() should use ffs_hdr_free() 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Cyril Bur --- libflash/libffs.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libflash/libffs.c b/libflash/libffs.c index 1684388f..822169b7 100644 --- a/libflash/libffs.c +++ b/libflash/libffs.c @@ -428,14 +428,32 @@ out: return rc; } -void ffs_close(struct ffs_handle *ffs) +static void __hdr_free(struct ffs_hdr *hdr) { struct ffs_entry *ent, *next; - list_for_each_safe(&ffs->hdr.entries, ent, next, list) { + list_for_each_safe(&hdr->entries, ent, next, list) { list_del(&ent->list); free(ent); } + if (hdr->side) { + hdr->side->side = NULL; + ffs_hdr_free(hdr->side); + } +} + +int ffs_hdr_free(struct ffs_hdr *hdr) +{ + printf("Freeing hdr\n"); + __hdr_free(hdr); + free(hdr); + + return 0; +} + +void ffs_close(struct ffs_handle *ffs) +{ + __hdr_free(&ffs->hdr); if (ffs->cache) free(ffs->cache); @@ -889,24 +907,6 @@ int ffs_hdr_new(uint32_t block_size, uint32_t block_count, struct ffs_hdr **r) return 0; } -int ffs_hdr_free(struct ffs_hdr *hdr) -{ - struct ffs_entry *ent, *next; - - printf("Freeing hdr\n"); - list_for_each_safe(&hdr->entries, ent, next, list) { - list_del(&ent->list); - free(ent); - } - if (hdr->side) { - hdr->side->side = NULL; - ffs_hdr_free(hdr->side); - } - free(hdr); - - return 0; -} - int ffs_update_act_size(struct ffs_handle *ffs, uint32_t part_idx, uint32_t act_size) {