Message ID | 1501765798-14200-1-git-send-email-rasland@mellanox.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 9511A377E; Thu, 3 Aug 2017 15:10:16 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0059.outbound.protection.outlook.com [104.47.2.59]) by dpdk.org (Postfix) with ESMTP id 2AA04374F for <dev@dpdk.org>; Thu, 3 Aug 2017 15:10:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=axFzXDA80Es9e8M6pDdO1nt/3Vfe9S9s04b4mkd4C6A=; b=Gl+DVybaoGDMW0By0uEIDV2jXF1EW/SFD4EkGH1dpvi1k6opv7bt+y/5z4RU0VCvXJb4l9gxCwwqiDEeuR3lFdD9HrXVXK0TEG4ZXJ06zMQdhCK5JoYEtY4zHHxP3B0JbUrtJ6JUCfdwOdaT7qpg1U06BeqzSlgDZaUFVEp0zPI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM2PR05MB1217.eurprd05.prod.outlook.com (2a01:111:e400:8450::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1304.22; Thu, 3 Aug 2017 13:10:12 +0000 From: rasland@mellanox.com To: gaetan.rivet@6wind.com Cc: dev@dpdk.org, thomas@monjalon.net, Raslan Darawsheh <rasland@mellanox.com> Date: Thu, 3 Aug 2017 16:09:58 +0300 Message-Id: <1501765798-14200-1-git-send-email-rasland@mellanox.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR0202CA0022.eurprd02.prod.outlook.com (2603:10a6:3:8c::32) To AM2PR05MB1217.eurprd05.prod.outlook.com (2a01:111:e400:8450::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8bc2284f-81a0-40c6-6bc5-08d4da70fa12 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM2PR05MB1217; X-Microsoft-Exchange-Diagnostics: 1; AM2PR05MB1217; 3:sUgPPv+Ao0S4bw1XJmPFlworgBY0XrzMsbu+hFSMdy0RsZ67D5BNDsJrGDzjWwyBjHqdaTw0AfoeBI9S+oUMoe9Td+2SbXzjzoPmRuyjomnkkDHcC7qNhPj0YhjvltIoaEEF8kAp0+i3yPztCAhy2We6YfB7LCIXV0tICXUJ//tj/pmhNPxdfoc6LcQlBPtXVRHVN1XYjUNPXvEcW7aelOgACTT43B6HcQ5wo0NWc/jqUikCkb1na6OUsAOSd4WW; 25:cJ8HUNWnfiI+avEEsX+6hadTqzZw9DWPw5k8NOwjcqVoZgi0d0yRs9y/gCQcTdYVAfEN0m/vBg54IjyRiCiDYTfbWpspBFYKLGql1e/7DHlcSvVY2QSBHw7KK8BkMBKpeC7xKXZGJbLliseUVZqik+EjeADvuMr9F/Ani6Aerq+QZlhVL7ooFsonYIYdRuMdu0pjB6KPgX3IkP93Cy3XKJhUXu1gKmb9+aj4To3GEcUierlWEnxSZ5kHCQSROJbhKvEcE76x/CNm1PPGjaYs//zsnQD3Chhgz2wtB9O0iLRm1AK1DxhdNPb5nDFRMVGwmg/gdq8sY1yqBfoPYljpIg==; 31:E375ldni600pRJv4AwSC+VcvavfLs/HBFwRaYmK9anPNnLVE99IjWjQ9WEgWq7fevmEHMimUUqONjURZ8otLHj4rktWAObq5BALSArB6R8wmX1/HRRyhLXQX7BkK2/uDgMLdPo9Q9eCoIVjjtMaQu5JGYYt4bUW7aQQvN7u4m/j2ezvDO1VXT4nHuc/Q4zTijCadsD7BcMD4W6y1MP9S54bgDhQZ8F6sP6iiYeSp/sc= X-MS-TrafficTypeDiagnostic: AM2PR05MB1217: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM2PR05MB1217; 20:Hv6xtX15qoMNFN50fKpIxg1k6YoZ9QqakrH8iILlANq8E6/elKivQMVI+x8khJTsKWrRAm/hxXLwPogXT+zlcrTl9JIiDAs9Az8r60zxmeSaautRrlhTQSVRuJE++IHdy3KtysE708SmuRIAkIeIbSc0ZExiG02F+rhDQAc3YP0jOjhZG22l02roYBB96VwNHfrwtnAT1KZEPFaTxyDnaTd7DHBENQRWc0JPAlsPPgbe792KQJuW/xownaCT3s2XdohjYoXzCLPZRvGSY0lG5E9xtOdCkSW/rRWZUhcMUuOqJENmjMMqeZ1Tu8VUXEhygO4+PurKm+lge58TOVyARp17CKyQFhrUgVVNi630gLZyyHImfdn5u1UysaVw4gI8lcoRYukMEH9NQtyW5LBWAT2+uBUHtEvdKzPxDRzgFdD6BFfiuFgBULGDVMUIquWiXVEYmMXRkPtU7eEabK5PywPW2a+uVtilFrMz++Ml4U2iJZ6nUwQreYNYuYFK4FNP; 4:EhQr2WLLH/yxwDwoF5uuuDI+84LLFAEim4GqGiXMsptfywvaNiAhiIj0xVsY3Ha0NEt4+PZ35xHbfUEeswSQEbnRQkMUU/Y2GbnAyu/lBoLHYR0atZFQuP/LgQI1p2q5zy2NCmrQO8Mitgxt08yTa4jzq38M3dklK/WQGGTQafKwo7htnIw/pQ4wPll3eNrS8nXyF7yd+VyYaEEfR+tGpIc3zqY3FxJxDpqaG073Liugz6AIigNLGDLDEbTnvnai X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: <AM2PR05MB121734348B3659536972A63FC2B10@AM2PR05MB1217.eurprd05.prod.outlook.com> X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM2PR05MB1217; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM2PR05MB1217; X-Forefront-PRVS: 03883BD916 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(39850400002)(39410400002)(39400400002)(39450400003)(39840400002)(199003)(189002)(36756003)(21086003)(33646002)(81156014)(106356001)(81166006)(5003940100001)(6666003)(47776003)(33026002)(66066001)(3846002)(107886003)(110136004)(189998001)(9686003)(38730400002)(6116002)(6916009)(53936002)(55016002)(50986999)(101416001)(25786009)(50226002)(42186005)(4326008)(2906002)(305945005)(69596002)(68736007)(86362001)(50466002)(48376002)(2361001)(2351001)(105586002)(7736002)(8676002)(85782001)(97736004)(7350300001)(5660300001)(478600001)(85772001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR05MB1217; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM2PR05MB1217; 23:n7g1bstglwPlzphCi8lfnKz20K9Ac/e7xBESGnY6Y?= 386lAxZpRjpWJS3ZaxSnh1359tIabRwtnWZ93Ac47e1GJtL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AQ28jD74= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2017 13:10:12.2942 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR05MB1217 Subject: [dpdk-dev] [PATCH] net/failsafe: fix for missing pclose after popen X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | warning | coding style issues |
ci/Intel-compilation | success | Compilation OK |
Commit Message
Raslan Darawsheh
Aug. 3, 2017, 1:09 p.m. UTC
From: Raslan Darawsheh <rasland@mellanox.com> When there is no prefered device, failsafe will always try to scan for prefered device. And if there is no device found with the exec option, popen() will get an empty output. In this case, it was forgotten to close the file descriptor.o it is fixed by closing the file descriptor even if the output is emtpy. Fixes: a0194d82 ("net/failsafe: add flexible device definition") Signed-off-by: Raslan Darawsheh <rasland@mellanox.com> --- drivers/net/failsafe/failsafe_args.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
Comments
Hi Raslan, I sent a patch earlier regarding this but we will use yours. Two small nits below. On Thu, Aug 03, 2017 at 04:09:58PM +0300, rasland@mellanox.com wrote: > From: Raslan Darawsheh <rasland@mellanox.com> > > When there is no prefered device, failsafe will always > try to scan for prefered device. And if there is no device > found with the exec option, popen() will get an empty output. > In this case, it was forgotten to close the file descriptor.o > it is fixed by closing the file descriptor even if the output is emtpy. > Good job on finding the issue and fixing it. It has been assigned a coverity ID: Coverity issue: 158633 > Fixes: a0194d82 ("net/failsafe: add flexible device definition") > The fixline should be 12-char long I think: Fixes: a0194d828100 ("net/failsafe: add flexible device definition") > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com> Otherwise: Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com> > --- > drivers/net/failsafe/failsafe_args.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c > index 932e371..3f92a77 100644 > --- a/drivers/net/failsafe/failsafe_args.c > +++ b/drivers/net/failsafe/failsafe_args.c > @@ -115,7 +115,7 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) > char output[DEVARGS_MAXLEN + 1]; > size_t len; > int old_err; > - int ret; > + int ret, pclose_ret; > > RTE_ASSERT(cmdline != NULL || sdev->cmdline != NULL); > if (sdev->cmdline == NULL) { > @@ -145,7 +145,8 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) > /* We only read one line */ > if (fgets(output, sizeof(output) - 1, fp) == NULL) { > DEBUG("Could not read command output"); > - return -ENODEV; > + ret = -ENODEV; > + goto ret_pclose; > } > fs_sanitize_cmdline(output); > ret = fs_parse_device(sdev, output); > @@ -154,12 +155,12 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) > goto ret_pclose; > } > ret_pclose: > - ret = pclose(fp); > - if (ret) { > - ret = errno; > + pclose_ret = pclose(fp); > + if (pclose_ret) { > + pclose_ret = errno; > ERROR("pclose: %s", strerror(errno)); > errno = old_err; > - return ret; > + return pclose_ret; > } > return ret; > } > -- > 2.7.4 >
03/08/2017 15:58, Gaëtan Rivet: > Hi Raslan, > > I sent a patch earlier regarding this but we will use yours. > Two small nits below. > > On Thu, Aug 03, 2017 at 04:09:58PM +0300, rasland@mellanox.com wrote: > > From: Raslan Darawsheh <rasland@mellanox.com> > > > > When there is no prefered device, failsafe will always > > try to scan for prefered device. And if there is no device > > found with the exec option, popen() will get an empty output. > > In this case, it was forgotten to close the file descriptor.o > > it is fixed by closing the file descriptor even if the output is emtpy. > > > > Good job on finding the issue and fixing it. > It has been assigned a coverity ID: > > Coverity issue: 158633 > > Fixes: a0194d82 ("net/failsafe: add flexible device definition") > > > > The fixline should be 12-char long I think: > Fixes: a0194d828100 ("net/failsafe: add flexible device definition") > > > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com> > > Otherwise: > > Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com> Applied, thanks
diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c index 932e371..3f92a77 100644 --- a/drivers/net/failsafe/failsafe_args.c +++ b/drivers/net/failsafe/failsafe_args.c @@ -115,7 +115,7 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) char output[DEVARGS_MAXLEN + 1]; size_t len; int old_err; - int ret; + int ret, pclose_ret; RTE_ASSERT(cmdline != NULL || sdev->cmdline != NULL); if (sdev->cmdline == NULL) { @@ -145,7 +145,8 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) /* We only read one line */ if (fgets(output, sizeof(output) - 1, fp) == NULL) { DEBUG("Could not read command output"); - return -ENODEV; + ret = -ENODEV; + goto ret_pclose; } fs_sanitize_cmdline(output); ret = fs_parse_device(sdev, output); @@ -154,12 +155,12 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) goto ret_pclose; } ret_pclose: - ret = pclose(fp); - if (ret) { - ret = errno; + pclose_ret = pclose(fp); + if (pclose_ret) { + pclose_ret = errno; ERROR("pclose: %s", strerror(errno)); errno = old_err; - return ret; + return pclose_ret; } return ret; }