From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5B94AA0350; Tue, 22 Feb 2022 09:28:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 48A2E41143; Tue, 22 Feb 2022 09:28:28 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 08FE441143 for ; Tue, 22 Feb 2022 09:28:25 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21LLMKsb005701; Tue, 22 Feb 2022 00:28:25 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Uks8H2JcRXr22fg9VjealdKS2kZ7XMusR4e5qf0GdTE=; b=Pj3Ea8jGTC8FYbsI2dH4p5xIkrI7F+wMYZNPSocQqCoyqnJ1mFQGOmV3f6oZ4H2n0FJd 6/ITq3rcUwyur/RBfOUPpq1peF0POS2C1cb1NQOmBk2uj1hPT85R4k3bQgHmd9yhz97h ZYOQLPywoEJuCXOIbckRVOgJOVvoROeoB3HO5FY7uPUg/GpKybg+IfHox3NOPt1AR6cy YftBXMLewo2rpxhE+wIRZTRWfp6LLowCb/lYaePd36BgvO2tOTo7eRrfKvDj0wPGiB7h VyiH1Ze3Krb5sQHBkqjxj2kwb9V/EbirS3+o7kmGAcBzwAuy25SOx26HeTXl9wus0GPE Og== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3eccerbbh2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 22 Feb 2022 00:28:25 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 22 Feb 2022 00:28:23 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 22 Feb 2022 00:28:23 -0800 Received: from localhost.localdomain (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 0372C3F7080; Tue, 22 Feb 2022 00:28:21 -0800 (PST) From: Tomasz Duszynski To: , Jakub Palider , Tomasz Duszynski CC: , Subject: [PATCH 1/2] raw/cnxk_gpio: fix resource leak Date: Tue, 22 Feb 2022 09:28:16 +0100 Message-ID: <20220222082817.1057701-2-tduszynski@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222082817.1057701-1-tduszynski@marvell.com> References: <20220222082817.1057701-1-tduszynski@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: OBdlhSspCyTaoG9M-d0qrXDUfrehPe9g X-Proofpoint-GUID: OBdlhSspCyTaoG9M-d0qrXDUfrehPe9g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-22_02,2022-02-21_02,2021-12-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org All used resources need to be properly cleaned up in error path. Fixes: 0e6557b448fa ("raw/cnxk_gpio: add self test") Coverity issue: 376504 Signed-off-by: Tomasz Duszynski Reviewed-by: Jerin Jacob Kollanukkaran --- drivers/raw/cnxk_gpio/cnxk_gpio.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c b/drivers/raw/cnxk_gpio/cnxk_gpio.c index 4ff132861d..9577753851 100644 --- a/drivers/raw/cnxk_gpio/cnxk_gpio.c +++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c @@ -178,24 +178,30 @@ cnxk_gpio_parse_allowlist(struct cnxk_gpiochip *gpiochip) static int cnxk_gpio_read_attr(char *attr, char *val) { + int ret, ret2; FILE *fp; - int ret; fp = fopen(attr, "r"); if (!fp) return -errno; ret = fscanf(fp, "%s", val); - if (ret < 0) - return -errno; - if (ret != 1) - return -EIO; + if (ret < 0) { + ret = -errno; + goto out; + } + if (ret != 1) { + ret = -EIO; + goto out; + } - ret = fclose(fp); - if (ret) - return -errno; + ret = 0; +out: + ret2 = fclose(fp); + if (!ret) + ret = ret2; - return 0; + return ret; } static int -- 2.25.1