From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F705A0613 for ; Wed, 25 Sep 2019 08:03:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 820932C58; Wed, 25 Sep 2019 08:03:49 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id EED552C36; Wed, 25 Sep 2019 08:03:46 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Sep 2019 23:03:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,546,1559545200"; d="scan'208";a="189579765" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga007.fm.intel.com with ESMTP; 24 Sep 2019 23:03:45 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 24 Sep 2019 23:03:45 -0700 Received: from BGSMSX107.gar.corp.intel.com (10.223.4.191) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 24 Sep 2019 23:03:45 -0700 Received: from bgsmsx103.gar.corp.intel.com ([169.254.4.16]) by BGSMSX107.gar.corp.intel.com ([169.254.9.96]) with mapi id 14.03.0439.000; Wed, 25 Sep 2019 11:33:39 +0530 From: "Poornima, PallantlaX" To: "dev@dpdk.org" CC: "Pattan, Reshma" , "Parthasarathy, JananeeX M" , "ravi1.kumar@amd.com" , "stable@dpdk.org" Thread-Topic: [PATCH] net/axgbe: fix double unlock coverity issue Thread-Index: AQHVbtnBmoCmUWDS30CqmN7x3hAsd6c778EA Date: Wed, 25 Sep 2019 06:03:38 +0000 Message-ID: References: <1568890907-10123-1-git-send-email-pallantlax.poornima@intel.com> In-Reply-To: <1568890907-10123-1-git-send-email-pallantlax.poornima@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.223.10.10] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] net/axgbe: fix double unlock coverity issue 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" Hi, >-----Original Message----- >From: Poornima, PallantlaX >Sent: Thursday, September 19, 2019 4:32 PM >To: dev@dpdk.org >Cc: Pattan, Reshma ; Parthasarathy, JananeeX M >; ravi1.kumar@amd.com; Poornima, >PallantlaX ; stable@dpdk.org >Subject: [PATCH] net/axgbe: fix double unlock coverity issue > >One issue caught by Coverity 340835 >*unlock: axgbe_phy_set_mode unlocks pdata->phy_mutex >*double_unlock: axgbe_phy_sfp_detect unlocks pdata->phy_mutex while it is >unlocked. > >In axgbe_phy_sfp_detect()/axgbe_phy_set_redrv_mode(), >axgbe_phy_get_comm_ownership() and axgbe_phy_put_comm_ownership() >are invoked subsequently. > >Currently in axgbe_phy_get_comm_ownership(), during one of the case >'phy_data->comm_owned' is not protected and before returning 0, lock is no= t >called and unlock is called in axgbe_phy_put_comm_ownership() directly >which is incorrect. > >Ideally, the variable 'phy_data->comm_owned' needs to be protected. >During success scenario, lock is called in axgbe_phy_get_comm_ownership() >followed by unlock in axgbe_phy_put_comm_ownership(). >In failure case, unlock is invoked in axgbe_phy_get_comm_ownership() itsel= f >appropriately. > >The fix is to protect 'phy_data->comm_owned' in the identified case ensuri= ng >locks/unlocks properly exist. > >Coverity issue: 340835 >Fixes: a5c7273771 ("net/axgbe: add phy programming APIs") >Cc: stable@dpdk.org > >Signed-off-by: Pallantla Poornima >--- > drivers/net/axgbe/axgbe_phy_impl.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > Request for review. Thanks, Poornima