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 50FD1A04F0 for ; Tue, 10 Dec 2019 16:00:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 45E1F1BE3D; Tue, 10 Dec 2019 16:00:24 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 164DA1BE84 for ; Tue, 10 Dec 2019 16:00:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575990022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aMYOV0gbR4mIQRjlBX9JZdrG/u2DbfUlK5c5wtixoOc=; b=hkZwE+Xgjj8NLh7HYLXJiquAJcChaDfQaLvqdhCUokTzojaoBSNO0dnT2dGpWAZthXbE8j HmJtGoCUH0kBMJ8KghNAhaDv8P+/bZnF5A9vyV46Md2ecy1TDUn64P882bloSwzgqZMVlQ 4x9cDWpVlPhZI0QGTkMetbcwi5fJApo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-Hj4wR_GcPzaqvBn0cL_Gvg-1; Tue, 10 Dec 2019 10:00:20 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FEAA911EA; Tue, 10 Dec 2019 15:00:19 +0000 (UTC) Received: from rh.redhat.com (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C3C95D9C5; Tue, 10 Dec 2019 15:00:17 +0000 (UTC) From: Kevin Traynor To: Pallantla Poornima Cc: Ravi Kumar , dpdk stable Date: Tue, 10 Dec 2019 14:58:45 +0000 Message-Id: <20191210145937.32755-11-ktraynor@redhat.com> In-Reply-To: <20191210145937.32755-1-ktraynor@redhat.com> References: <20191210145937.32755-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: Hj4wR_GcPzaqvBn0cL_Gvg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'net/axgbe: fix double unlock' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/16/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/3c53ea193553308b5f= c9788b5d32ba2cf5a4b440 Thanks. Kevin. --- >From 3c53ea193553308b5fc9788b5d32ba2cf5a4b440 Mon Sep 17 00:00:00 2001 From: Pallantla Poornima Date: Thu, 19 Sep 2019 12:01:47 +0100 Subject: [PATCH] net/axgbe: fix double unlock [ upstream commit c8c2296b5974ab369c942cc4cada923193018eb9 ] 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 not 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() itself appropriately. The fix is to protect 'phy_data->comm_owned' in the identified case ensuring locks/unlocks properly exist. Coverity issue: 340835 Fixes: a5c7273771e8 ("net/axgbe: add phy programming APIs") Signed-off-by: Pallantla Poornima Acked-by: Ravi Kumar --- drivers/net/axgbe/axgbe_phy_impl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_p= hy_impl.c index 973177f69..2267c5f81 100644 --- a/drivers/net/axgbe/axgbe_phy_impl.c +++ b/drivers/net/axgbe/axgbe_phy_impl.c @@ -413,7 +413,4 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_po= rt *pdata) =09unsigned int mutex_id; =20 -=09if (phy_data->comm_owned) -=09=09return 0; - =09/* The I2C and MDIO/GPIO bus is multiplexed between multiple devices, =09 * the driver needs to take the software mutex and then the hardware @@ -422,4 +419,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_po= rt *pdata) =09pthread_mutex_lock(&pdata->phy_mutex); =20 +=09if (phy_data->comm_owned) +=09=09return 0; + =09/* Clear the mutexes */ =09XP_IOWRITE(pdata, XP_I2C_MUTEX, AXGBE_MUTEX_RELEASE); --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-10 14:49:39.834476239 +0000 +++ 0011-net-axgbe-fix-double-unlock.patch=092019-12-10 14:49:38.996458812 = +0000 @@ -1 +1 @@ -From c8c2296b5974ab369c942cc4cada923193018eb9 Mon Sep 17 00:00:00 2001 +From 3c53ea193553308b5fc9788b5d32ba2cf5a4b440 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit c8c2296b5974ab369c942cc4cada923193018eb9 ] + @@ -31 +32,0 @@ -Cc: stable@dpdk.org