From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F22F258FE for ; Thu, 11 Apr 2019 02:28:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 17:28:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,335,1549958400"; d="scan'208";a="133232658" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga008.jf.intel.com with ESMTP; 10 Apr 2019 17:28:09 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 10 Apr 2019 17:28:08 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 10 Apr 2019 17:28:08 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.92]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.39]) with mapi id 14.03.0415.000; Thu, 11 Apr 2019 08:28:06 +0800 From: "Xu, Rosen" To: Li Qiang , "Zhang, Tianfei" CC: "dev@dpdk.org" , "liq3ea@gmail.com" Thread-Topic: [PATCH v2] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr Thread-Index: AQHU76N4OqlWvpLns0iMXdZ1JmW8IqY2GvLg Date: Thu, 11 Apr 2019 00:28:05 +0000 Message-ID: <0E78D399C70DA940A335608C6ED296D73A69A8E5@SHSMSX104.ccr.corp.intel.com> References: <20190410134313.5815-1-liq3ea@163.com> In-Reply-To: <20190410134313.5815-1-liq3ea@163.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODhhNzE0NzYtMjQ1Yi00ZTA5LThmNjctNjk2NDJmMTVlMDMxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTERlR0h0ZmZRY2FsOTl6Y2tHTlRkNUtmTVhOMzluMmtWY1FTR05oTFRUeGp2WjJPUnB4RmF4TFJialhsK1V2eSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Apr 2019 00:28:15 -0000 > -----Original Message----- > From: Li Qiang [mailto:liq3ea@163.com] > Sent: Wednesday, April 10, 2019 21:43 > To: Xu, Rosen ; Zhang, Tianfei > > Cc: dev@dpdk.org; liq3ea@gmail.com; Li Qiang > Subject: [PATCH v2] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr >=20 > In rte_fpga_do_pr() function, if 'stat' return error the 'file_fd' is nev= er closed > thus leading a fd leak. This patch avoids this. It's a bug fix, so pls add 'Fix XXX'. =20 > Spotted by Coverity: CID 27441 It should be Coverity issue: 279441 > Signed-off-by: Li Qiang pls add: Cc: stable@dpdk.org > --- > Changes since v1: fill ret before goto close_fd per Rosen's review >=20 > drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c > b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c > index da772d026..eff001b59 100644 > --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c > +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c > @@ -244,7 +244,8 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int > port_id, > if (ret) { > IFPGA_RAWDEV_PMD_ERR("stat on bitstream file > failed: %s\n", > file_name); > - return -EINVAL; > + ret =3D -EINVAL; > + goto close_fd; > } > buffer_size =3D file_stat.st_size; > IFPGA_RAWDEV_PMD_INFO("bitstream file size: %zu\n", buffer_size); > -- > 2.17.1 >=20 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 4E862A0096 for ; Thu, 11 Apr 2019 02:28:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1EA6D1B114; Thu, 11 Apr 2019 02:28:17 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F22F258FE for ; Thu, 11 Apr 2019 02:28:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 17:28:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,335,1549958400"; d="scan'208";a="133232658" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga008.jf.intel.com with ESMTP; 10 Apr 2019 17:28:09 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 10 Apr 2019 17:28:08 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 10 Apr 2019 17:28:08 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.92]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.39]) with mapi id 14.03.0415.000; Thu, 11 Apr 2019 08:28:06 +0800 From: "Xu, Rosen" To: Li Qiang , "Zhang, Tianfei" CC: "dev@dpdk.org" , "liq3ea@gmail.com" Thread-Topic: [PATCH v2] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr Thread-Index: AQHU76N4OqlWvpLns0iMXdZ1JmW8IqY2GvLg Date: Thu, 11 Apr 2019 00:28:05 +0000 Message-ID: <0E78D399C70DA940A335608C6ED296D73A69A8E5@SHSMSX104.ccr.corp.intel.com> References: <20190410134313.5815-1-liq3ea@163.com> In-Reply-To: <20190410134313.5815-1-liq3ea@163.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODhhNzE0NzYtMjQ1Yi00ZTA5LThmNjctNjk2NDJmMTVlMDMxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTERlR0h0ZmZRY2FsOTl6Y2tHTlRkNUtmTVhOMzluMmtWY1FTR05oTFRUeGp2WjJPUnB4RmF4TFJialhsK1V2eSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190411002805.Krr7TqDkk_V1JMsM6yFlGU4KfzRZbn4cNlQSLOjx-Jw@z> > -----Original Message----- > From: Li Qiang [mailto:liq3ea@163.com] > Sent: Wednesday, April 10, 2019 21:43 > To: Xu, Rosen ; Zhang, Tianfei > > Cc: dev@dpdk.org; liq3ea@gmail.com; Li Qiang > Subject: [PATCH v2] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr >=20 > In rte_fpga_do_pr() function, if 'stat' return error the 'file_fd' is nev= er closed > thus leading a fd leak. This patch avoids this. It's a bug fix, so pls add 'Fix XXX'. =20 > Spotted by Coverity: CID 27441 It should be Coverity issue: 279441 > Signed-off-by: Li Qiang pls add: Cc: stable@dpdk.org > --- > Changes since v1: fill ret before goto close_fd per Rosen's review >=20 > drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c > b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c > index da772d026..eff001b59 100644 > --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c > +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c > @@ -244,7 +244,8 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int > port_id, > if (ret) { > IFPGA_RAWDEV_PMD_ERR("stat on bitstream file > failed: %s\n", > file_name); > - return -EINVAL; > + ret =3D -EINVAL; > + goto close_fd; > } > buffer_size =3D file_stat.st_size; > IFPGA_RAWDEV_PMD_INFO("bitstream file size: %zu\n", buffer_size); > -- > 2.17.1 >=20