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 5E943A0543; Mon, 13 Jun 2022 08:40:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D7484021E; Mon, 13 Jun 2022 08:40:29 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id DEC9440150; Mon, 13 Jun 2022 08:40:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655102428; x=1686638428; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=nV7AKjS5+9CZ2KX4tV6IckY0Snbu20cySzxCvLT+c14=; b=JWq3Rim31K4pI7zfljGNVjZKhE8gLoFx9VzVi8O3bYQcPJpGCg+qjRkm yPw0WHEX0VWNXZgZlHBWRoD4cmQ6vFz1X7+lMlJZCoXAQdtdCJbKYac6v LZuH1h8uYvW9Y2ZLu9xxsPpIVRuCArka6WeMA+KbhFF+BrmyiSnXz1wrv YHoC6JTREO+HG8tHWQ5sMcCib2MtJkj4wZIHS4Kw/gEmgtDVQqI1Pl2gd a+gfLDuVEvE2SIIVA+A5a+7sHvAvuIp+1wCW10ntBVlfW6ihh8zDGAyxa eX9eWI6SO5JrdwDu0BRxuIQAkTyIjMRQEqDENZquGopVi7kxH2e3rrV+F Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10376"; a="339858791" X-IronPort-AV: E=Sophos;i="5.91,296,1647327600"; d="scan'208";a="339858791" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2022 23:40:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,296,1647327600"; d="scan'208";a="829636758" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga006.fm.intel.com with ESMTP; 12 Jun 2022 23:40:26 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Sun, 12 Jun 2022 23:40:25 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Sun, 12 Jun 2022 23:40:25 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.170) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Sun, 12 Jun 2022 23:40:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E/kNgfnJ7s/NzErDaGV44/I24VEv0fbAEChkJ59nH0SNA81QkWZXrMXf473JbOjaCViIbaFazYFUlWVx9Rvwd/NGcVqJpQ6gHB2rTVllChBwmFgkCGLpqyf7lU3DzcFh+AsBL6oz+ciJ1vma1o0PZDQuCU0Eq0F8Ynjl772zR7AIfJhNaI+iXzB1+wBzd8hbKySP3IrK95sUII2jDNHxBN+1UoKyjxtXWJ3sqiz44o2P6c2xxTYrAYjyjqmorDvhy3BvEabnHVXrv2sgC9tG+Ra8bSHV+Al7Vd6QA8WPn5t8oyIHzBQNnyq+Fd1k5rx5rEHB/dwkX6vfDQOXyKG+lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BAX+xCDaP/j37Wydr4lNhE2/V6y9GpABu8Ra4tzpB8I=; b=VOi0LXExRt+d3PhXWLDYGkAxR3APARN/Cqh9GofNrxJ7t1/dqzm8f8MajVPnrAt/fn10cGKUY3RgmGEg1f92y8o10hOMINumkJlI7np856OgQt2SQpRSAuxxMp6zEPnJXAZx+RzASkB9z3y9ctMNlQOjuswnc4y9aRmV3yPY3je15o5b6qrpDUp8rpciK5B1KH987QHocFYwXTJXqm4d0r7wk30LVHvAtiMy/TnPhbU2oL7enZ3HsJ2zJTP3c8gDRvaH9qVsWpEHf/xSdz9gQzY93cCUcHgNbHR8QN+f/zN7hTglacF6g2mHzBknLPhSg8aOMbxU62Vc5p8KiSHRHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by PH7PR11MB6522.namprd11.prod.outlook.com (2603:10b6:510:212::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.20; Mon, 13 Jun 2022 06:40:03 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::a113:c892:d94:dd10]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::a113:c892:d94:dd10%6]) with mapi id 15.20.5332.020; Mon, 13 Jun 2022 06:40:03 +0000 From: "Zhang, Tianfei" To: "Huang, Wei" , "dev@dpdk.org" , "thomas@monjalon.net" , "nipun.gupta@nxp.com" , "hemant.agrawal@nxp.com" CC: "stable@dpdk.org" , "Xu, Rosen" , "Zhang, Qi Z" Subject: RE: [PATCH v1] raw/ifpga: free file handle before function return Thread-Topic: [PATCH v1] raw/ifpga: free file handle before function return Thread-Index: AQHYe9ziYov5l/QMTk6Axucm70vFB61M6OiQ Date: Mon, 13 Jun 2022 06:40:03 +0000 Message-ID: References: <1654764609-8057-1-git-send-email-wei.huang@intel.com> In-Reply-To: <1654764609-8057-1-git-send-email-wei.huang@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 20a16a82-13d8-47a4-34a5-08da4d078c18 x-ms-traffictypediagnostic: PH7PR11MB6522:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Y+aHz74ACfxQmUCgF9GiJm1E0cuCjTIIRjJMKldydgUyMs+ogtaI7xE/E6K+nSFj9xifEeEBzF1u0W/9YxX4j68W+ZTfk8iXlAv6Cjt4wI7UPve7FuN6LhiHEZHuRelPD82DDNhpG5kczqX3/SuksfY48v/OQgvOyNS/KkxJOGWHuae41f2LJjSsB37mNof1tkS0/DUhhDIophgZvuUGOQmz8hYYI8CpGg5qPwZHcP2Yeqi4goEPmN/LfdIKzhlhh0dOicpsHEux+HMapOX9CY7Nynjbj/4zOWGmcddpKPVX8Nns6Jn5KXwnuYRHVFRwO2A+F/CG4eBG/eG1IWpHaKfMw9YFjNfRvdeufFg7HCqSAEUtBOrbuHkDHvj+xdbY3XpNtNOpt7Vt8chbOWmyDAv7CTSEW90cmipZcaLAYK3IRtfXO03Z/EZ23RDwSMZkJBz1r8hqyPziFWboZOUKqpzmVKbYguPXImiXw9BYJ6N5jqrme/2+VEOjlFlSxKcdBswr/cQIjQbX+R2uFZXxMOJsfRSUS5VWNFTCHjqw8WQ/BQo2T0a/W3JHFJuJcn3PsdS41SiEVHNSCKHtIFP/w3/UA0uDaydAnBIfDcMnvmJoxFecfmX2nmzFFOoOMxIFhkfE4sKUlpgpGYH0OeNLklzMvtDSxrtwpSAC5L0D5M4TqLk8ULIayfbWZ/nMjzavF8/6qsuO3Z6yJXSlllhCMQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR11MB5483.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(366004)(186003)(86362001)(83380400001)(82960400001)(71200400001)(54906003)(66446008)(66556008)(8676002)(66476007)(66946007)(64756008)(4326008)(55016003)(316002)(110136005)(76116006)(508600001)(107886003)(33656002)(53546011)(7696005)(6506007)(52536014)(5660300002)(8936002)(38070700005)(38100700002)(9686003)(122000001)(2906002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 2 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Eo861Rdzdo7O28svNw4VQKbpl0SeqGAGipRT7nmMdPPlj/rByr/5No6bDPGP?= =?us-ascii?Q?ow5YfnXM00i+GxeDSGM04dJbZfO9LN/DUQ4F6DLCEw7XLlZr7Slzh1WNW9Iu?= =?us-ascii?Q?W5lo2HAvtUHN8D8QeCxZIvVsrJW5qrcEXzaN+jvZIZHMa67P5IEYIbE5k0NU?= =?us-ascii?Q?eQ71m1pjn4DFfr30B9G1DASZOITFcFJVk9sV5qGCmIax4rqqdZfQyPhH0tje?= =?us-ascii?Q?yUn4nEcZ47Frf6yFqOhEz5nlEzWaczEQfq81KLbCxjmPqDfmHgseWeRz9G3a?= =?us-ascii?Q?LEq5kt3J4y6/q+vs807Bu23MqdgBTtHkH27JqkjprjIJsAWOHWZBFJ8coEak?= =?us-ascii?Q?CmOJCBVMhUoPMMjuD7r88tmyS2Zb2Gex9e4gKZvUzhd4+gqUkZQx27ubheG8?= =?us-ascii?Q?oiqV7Wxrlq32aQXpJ9yLQKpB6v2iXIvn1f6pOGRWEKIZa94b4DmQfFPCVrxH?= =?us-ascii?Q?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AQuzF984uQ6?= =?us-ascii?Q?Tm8LbAtqVf8CITrlYIBAf4e0qE0x7zFryMNAD1MefPn671y+p41ecpbZ2Skl?= =?us-ascii?Q?58fLmDekZKplk/ztsqJT9HLcUu3cBaWko3p/A5XyUX42SBgdbQZAJYnmunXs?= =?us-ascii?Q?4QO9p0fSZGgdH3q6jFWe12OkgJEdJffCfzPAVjZSdA6hBXWTnibKokfWfxtk?= =?us-ascii?Q?oBt4Jl7mOAzqM6zb8LB9VL7/KZWbnomxmR8gIOu8lbUHugk7idwF30qCm9dk?= =?us-ascii?Q?KAzWkAFBr85OSlHU5j8XbKHa43ExZlpURq4RW3lZB+s6PCkhX4tOK6y0Rcmz?= =?us-ascii?Q?ItSSxylnqps4lWFadMCVJzPSSuarQDndGV29y6KFgpNHCzFgc96lYkHekURh?= =?us-ascii?Q?lo7NkzGYoRmikirKHurvjIOC6yjn6aqb/dBpKfPA5kF44Gw+kpEX/OGiZ5Vk?= x-ms-exchange-antispam-messagedata-1: uAsboVE4wMGky3a42P0oQHcGssOqfEd2IWU= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20a16a82-13d8-47a4-34a5-08da4d078c18 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2022 06:40:03.6228 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BrLPycpZX5PnW0oneXM0Sy0xnYr2bYTkk5fVMt9QV5ABawyzcFX13qWYPEnEVv+f3xYQjj3oqLuR2LYe0xyH5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6522 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Huang, Wei > Sent: Thursday, June 9, 2022 4:50 PM > To: dev@dpdk.org; thomas@monjalon.net; nipun.gupta@nxp.com; > hemant.agrawal@nxp.com > Cc: stable@dpdk.org; Xu, Rosen ; Zhang, Tianfei > ; Zhang, Qi Z ; Huang, Wei > > Subject: [PATCH v1] raw/ifpga: free file handle before function return >=20 > Coverity issue: 379064 > Fixes: 673c897f4d73 ("raw/ifpga: support OFS card probing") >=20 > Signed-off-by: Wei Huang > --- > drivers/raw/ifpga/base/ifpga_enumerate.c | 28 +++++++++++++++++++-------= -- > 1 file changed, 19 insertions(+), 9 deletions(-) >=20 > diff --git a/drivers/raw/ifpga/base/ifpga_enumerate.c > b/drivers/raw/ifpga/base/ifpga_enumerate.c > index 7a5d264..61eb660 100644 > --- a/drivers/raw/ifpga/base/ifpga_enumerate.c > +++ b/drivers/raw/ifpga/base/ifpga_enumerate.c > @@ -837,8 +837,10 @@ static int find_dfls_by_vsec(struct dfl_fpga_enum_in= fo > *info) > vndr_hdr =3D 0; > ret =3D pread(fd, &vndr_hdr, sizeof(vndr_hdr), > voff + PCI_VNDR_HEADER); > - if (ret < 0) > - return -EIO; > + if (ret < 0) { > + ret =3D -EIO; > + goto free_handle; > + } > if (PCI_VNDR_HEADER_ID(vndr_hdr) =3D=3D > PCI_VSEC_ID_INTEL_DFLS && > pci_data->vendor_id =3D=3D PCI_VENDOR_ID_INTEL) > break; > @@ -846,19 +848,23 @@ static int find_dfls_by_vsec(struct > dfl_fpga_enum_info *info) >=20 > if (!voff) { > dev_debug(hw, "%s no DFL VSEC found\n", __func__); > - return -ENODEV; > + ret =3D -ENODEV; > + goto free_handle; > } >=20 > dfl_cnt =3D 0; > ret =3D pread(fd, &dfl_cnt, sizeof(dfl_cnt), voff + PCI_VNDR_DFLS_CNT); > - if (ret < 0) > - return -EIO; > + if (ret < 0) { > + ret =3D -EIO; > + goto free_handle; > + } >=20 > dfl_res_off =3D voff + PCI_VNDR_DFLS_RES; > if (dfl_res_off + (dfl_cnt * sizeof(u32)) > PCI_CFG_SPACE_EXP_SIZE) { > dev_err(hw, "%s DFL VSEC too big for PCIe config space\n", > __func__); > - return -EINVAL; > + ret =3D -EINVAL; > + goto free_handle; > } >=20 > for (i =3D 0; i < dfl_cnt; i++, dfl_res_off +=3D sizeof(u32)) { @@ -868= ,7 +874,8 > @@ static int find_dfls_by_vsec(struct dfl_fpga_enum_info *info) > if (bir >=3D PCI_MAX_RESOURCE) { > dev_err(hw, "%s bad bir number %d\n", > __func__, bir); > - return -EINVAL; > + ret =3D -EINVAL; > + goto free_handle; > } >=20 > len =3D pci_data->region[bir].len; > @@ -876,7 +883,8 @@ static int find_dfls_by_vsec(struct dfl_fpga_enum_inf= o > *info) > if (offset >=3D len) { > dev_err(hw, "%s bad offset %u >=3D %"PRIu64"\n", > __func__, offset, len); > - return -EINVAL; > + ret =3D -EINVAL; > + goto free_handle; > } >=20 > dev_debug(hw, "%s BAR %d offset 0x%x\n", __func__, bir, > offset); @@ -886,7 +894,9 @@ static int find_dfls_by_vsec(struct > dfl_fpga_enum_info *info) > dfl_fpga_enum_info_add_dfl(info, start, len, addr); > } >=20 > - return 0; > +free_handle: > + close(fd); > + return ret; > } >=20 > /* default method of finding dfls starting at offset 0 of bar 0 */ It looks good for me. Acked-by: Tianfei Zhang