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 5CA9AA054A for ; Wed, 15 Jun 2022 09:18:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F6F341145; Wed, 15 Jun 2022 09:18:40 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 2531240220; Wed, 15 Jun 2022 09:18:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655277517; x=1686813517; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=F7jvps/81Lz5KAA8flL0vZetidbckUDvPHd9GXo0VOI=; b=SvhaS6xzj7nx6GQ1LqbghaGT5kKMGLYSP3nAZtF/1XHexQ+YiJJc/T4E /Xa05XVGq8T4OwDXGF5pTBBqW0UXH++tqG9IB0dSAJug+CIPcDuT11dJl HOmlJSFyxAg8NBcAFlFXIlxryFdjxTQHskAsN3wN/m7ddaZuN5OQsvbp6 DoB8f5UWLobWNRHZ8HCso7dzsGwqOBUU+cROj2aW/PR4xjiyNVruy0y7M Nb2dkbR+qljOw9QUThTf0KbnZvDVCGvPpABolYGVBdo2esSZG682IYu+X 6mxMkyIe5iI2Op/zHYdV4Jo8mFqD7E7Ajj7JdeBdS0e4bJiWOQcOLVovQ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="276438113" X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="276438113" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 00:18:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="674337664" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jun 2022 00:18:26 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 15 Jun 2022 00:18:26 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Wed, 15 Jun 2022 00:18:26 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Wed, 15 Jun 2022 00:18:25 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kiEpfEinJxuMT3YE8KSUCTZHPsPjuEcN1297C2ICniiQNZYmp96hxsQzccHR0JGN9BfTmGuqgIurLF6ak+fPSz081nBskM6dWtZaWVpXtvunMnSIjDfe1w4L9dHE1MGe7rPNvX34H+0z3NZhNt9sA5v7qY78wGrUefXn5lyCu/gAw8yNkFzgAxk+fdX5p7WwVpJpieqj+GMg5TGbw8IYI0SXfAcrCLfAkQO4zAg21K65ZPU65UeZ6QqQQkBDEuuoT/J9pYQ2jD6tZJxr+PKkvW5Y+DcNGOfIq1fsTs2gnKLOG1iUcA9uoWZpFypKR7E8VhX7b6AUPVME0NxezaD7ZA== 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=60oeHDAngTg9t9dTaAYfI7nE2MsXyhIUQ+MZj7PYQA0=; b=J6HsLI9N+TRxmWVuJUG07xMnqOU3/WiRpSZeBijVqCPhOJOdNRvxxRsn25MKL/vBSkKEcgOfZ0upgKV1YkJFLYW0qKzGbpm1XoNKcVI58N3AL7KIYAkLr/LhObfVbNuvvlsmI8PmeC1dTihvWNb38IyiPYRXdZz2LRyy6Q4kkRNb3gqphRazKRsE0/tsQppZ7AyKEO6WAGFUHSzRk1V4p7pLgtbJxErdldxinkzGMW64j3qOLEO2bPj6WPSpKnLLZ4d8c3kPqITyIEdyuKopgL28ZmzR57A8YXWQovl/dES/YqDPD7vTHoV1+HdnPgmmuscvZrV5V3nLTfAs6WccEg== 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 DM6PR11MB4252.namprd11.prod.outlook.com (2603:10b6:5:201::26) by MW3PR11MB4665.namprd11.prod.outlook.com (2603:10b6:303:5d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Wed, 15 Jun 2022 07:18:24 +0000 Received: from DM6PR11MB4252.namprd11.prod.outlook.com ([fe80::b9d5:600c:9f13:bc96]) by DM6PR11MB4252.namprd11.prod.outlook.com ([fe80::b9d5:600c:9f13:bc96%7]) with mapi id 15.20.5332.023; Wed, 15 Jun 2022 07:18:24 +0000 From: "Xu, Rosen" To: "Huang, Wei" , "dev@dpdk.org" , "thomas@monjalon.net" , "nipun.gupta@nxp.com" , "hemant.agrawal@nxp.com" CC: "stable@dpdk.org" , "Zhang, Tianfei" , "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: AQHYe9zirdKUN0nYFE6YY7fr4/MrrK1QGF6w Date: Wed, 15 Jun 2022 07:18:24 +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: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzMxMzJhYTMtNzI0NS00OTU4LWExYTgtMTU0ZTIyZTBkOTkxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRXJBakFFdk0wdytpaHFsbWVUa09PNkNDNlUzMTFIWmgzalwvcUlNR0tCc2VaWHRzb25QVWF6d2h5aWozR0h6T2MifQ== x-ctpclassification: CTP_NT 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: cea5be84-762c-49dc-1d0a-08da4e9f3c41 x-ms-traffictypediagnostic: MW3PR11MB4665: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: /OGB8jg2C0arONujox7A2V2S3on5fvDen5b0g7zoFU1TLtEGFO3CG7widRJc5b6x/zym+HI5DnEixKZ3DlFmUdYroYhOQNGQGxcbjFjmqYzsuC98Xy6qQACo0AwvF1//kdF4kBKJ4rkh8bKmxATfEd5WZ/bfe6TfppqtOmSySn174UTh07jnC6oZpNqUIyMZrqSwjIK4fz0tWRTmhz9Bg7MyPu6+5kQhc6b13AIv3XtcjV9X8f4me6NbUkgHRJkEv1aJVAHwFMtG8LYCbL22CUDJAFhg9ED6pUpcOjbITmgx6sKIDh1VIhC5qVFE/Cg78GKjjcC5lrvZkF1Rsk85fYRFQ2x4Uh/nOU++d/t2DhFf50L+VHS+8xdM+xGpbMptHJQijvCnbmd6J5g+6tFgspn1o3lBS0VQs3PhKIXq7HXLCOqbQrl0n9wmKVwamCfPkDeiSVbN2AbXE8jD0VnFojgKlejYB72VleAsOhFa01dAjeS3M+1dcog55VLQyNT6MfTNyZtbFp9xLkg5nNJPlXGI1ozEWbGlN3SnGtUTffeWr//u6TsHR/rjiuz7PGGGV5PqaJ88r/GRq7OtxLk722sDHHSTPpx3GpmEAPIJIsRbZ8+vMpiyTht+yhYHJleExIZ0vE804DijZsM0v6GBX/QYYzIzs73ZiCOGQQZlI8WCozlv3NntI6MyVqIOpGwm9N1qQ7nD+PmHy8BFxN79uA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4252.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(366004)(5660300002)(7696005)(2906002)(8936002)(82960400001)(52536014)(33656002)(122000001)(86362001)(508600001)(38100700002)(186003)(83380400001)(66556008)(76116006)(66946007)(66446008)(66476007)(110136005)(38070700005)(53546011)(54906003)(26005)(316002)(4326008)(8676002)(55016003)(107886003)(71200400001)(9686003)(64756008)(6506007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?W0Q0P7cbHC2SgRCg7T2s35HhL77IfigFBGW1USuJScB0KfVVbVTRVE/CvKCD?= =?us-ascii?Q?GPEDxr4eOjInLcCvuD58nMGJVr+WVYPmn+/NDngr/BtHohelLgHkuDmjN6g8?= =?us-ascii?Q?iIqNJZX4FKQwODmugILDMV8oBQIom9MV7qcG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?9Te8EIiAuJm75AuMkGQMBzDiXzVuRJmqEgkMNbKi1SndH7x1ZHaEW8s9Eela?= =?us-ascii?Q?xs7Yh0vOvdHPRbWDNfhkah4TRRtuy901SeS/fIK6Ea7BXf2cJJIYm8luSKLm?= =?us-ascii?Q?D6Q+lX3Ffn31GJUx/9fSb/xNLlIJgFJGCmqSI0gRwJ2xezFxf/84IUatyUGi?= =?us-ascii?Q?nTj66e7FyY867XWIdG+QNQ617GKd7fkV8zBhwND2kFePLs57+8k2jZ7VHBDi?= =?us-ascii?Q?CyLoCdMI7jtkjZoCOZjMQS1AiI55Wdx8XPCZHoij15NuTlldwCdcfPOIzRVe?= =?us-ascii?Q?KwY4s3EeSy3inTcYw2D3IxqQFdjSmg67ICW8l8oHDvlCKsB5bSr/iR7dnmrA?= =?us-ascii?Q?v0GKDLGtSCpkUp3Ul9SlCIJfU/AxuaICdP9yTXAmqw5zqDReobblrFSpdnWI?= =?us-ascii?Q?y1hoNOJ3cCXOEonRtm69RdGouGkpDiH0noYHGALNCXTzc/Dx3d4kNBLOOPYi?= =?us-ascii?Q?yNetVMU7wR+HQisZLkd1cU7JXe4SScdtNNH6TwB+rVKOO0JiuNExotLizQsQ?= =?us-ascii?Q?SKTn8YKQE3jG9CwtDd2o4LpGm/X/OxF9khfN7gcQihwL1qpyqXS9Wx/i+qkC?= =?us-ascii?Q?1B9SUQfWiB4VhVCzolxd1c4wC+GFYoEDLUSZtO3KBk3tK1tCfE5qz5JPtOem?= =?us-ascii?Q?CFs+IjzO+cO71C1u+6nwb9zEpUnoXfcBrO4yB9Dh0yb0TMcSgH3kxIX3dXyd?= =?us-ascii?Q?qpUFbnsUdw=3D=3D?= 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: DM6PR11MB4252.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cea5be84-762c-49dc-1d0a-08da4e9f3c41 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jun 2022 07:18:24.3388 (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: TYTGzR8JY4rdju3G0M2/TXJLZ+H8jZ4vqJFNreY7GY5K+RSaMx4DrnIp+OchBJHlEQyfMA2zD2zsEClW/TQNFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4665 X-OriginatorOrg: intel.com X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi Wei, > -----Original Message----- > From: Huang, Wei > Sent: Thursday, June 09, 2022 16:50 > 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_info *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_info *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 */ > -- > 1.8.3.1 It looks good for me. Reviewed-by: Rosen Xu