Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp623958ybx; Wed, 6 Nov 2019 23:53:38 -0800 (PST) X-Google-Smtp-Source: APXvYqzah42bWv7DhD6Wf4AQvoO5jCoGcOXJSGY9hXpe/a8aCZC/w5hMNWOBtVYy3sRFRsIc5yQm X-Received: by 2002:a50:ab10:: with SMTP id s16mr2043856edc.118.1573113218284; Wed, 06 Nov 2019 23:53:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573113218; cv=none; d=google.com; s=arc-20160816; b=RfrhSi16oiu6qh6zifQeRyhp1UsKvDfbDZUrxt6rZRZwwTpH/Vw7XdYJ2zRFUw9mV6 M6UP9lHGQYMbZTdKZ4w1tXDyoCyy6kgyB7EYz9x5UMmwl5qHcLOVedgq5WcvLZL59EtN Blg0EJr3zVnQ0wURvdnBpl7rC2zWGrd7rUDE73ulOtn4aiJ94cpJg89DJZNjcvq1A/xT 2+G0gilhwYuubhvrkN4nzbyphnvAL76nAejLpz97Ocr//P+q99r9CVX9fxM+l65N+V+P hQixdJfvCkRlTIBiOvdqVNjRvGWrjSkvdWztJ4Qgvi9fsTjVhTuqdmbyAcYjZSA+tO8X mwAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=jWR+TnPhSA14NeH1OOvS+/rjTxIzSqL1OgNwBLErpNw=; b=AGoJc47YKNmkGDO9xPmyjCQCO8/YxQ7kzIRCR1y0BM6jgVDyG3d8LsBwH8n/G3Ojhp 8iC8aBzDo/B1Nro9FdSfHci+SxxL64TS9qq/qW/FiBsR8k/RVWxRy1auml/12luFzyfE Gvnrs/gGo3d3GzxOQUiQMN/y0CGW2UanIT/KS+dIAjucdOH+AKUChNEaD9/sL+1y3s+i 7bljJeWYiabilG2XsqbOHuF63jnqLXS8fwzqT4iKBBxdaPbl15IIBbwUPSYDi0ZLIm0l aRv1ifToHH1ZiwuhUTzNU1ukmlmRXIrshTlhGM49VSqY45UzWqTnYVVc2qvN2+FfJ6S+ 0URQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=OpLiqukL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j17si986922ejd.314.2019.11.06.23.53.14; Wed, 06 Nov 2019 23:53:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=OpLiqukL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733178AbfKGHtG (ORCPT + 99 others); Thu, 7 Nov 2019 02:49:06 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:41640 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbfKGHtF (ORCPT ); Thu, 7 Nov 2019 02:49:05 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xA77mfvP072483; Thu, 7 Nov 2019 07:49:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2019-08-05; bh=jWR+TnPhSA14NeH1OOvS+/rjTxIzSqL1OgNwBLErpNw=; b=OpLiqukL6/T+yKTuQ2BDkARL+NLCwAQ005TcrCbsaeEimafivol+/8UPC7zPUuu1nv54 epaUzQ/riizqshB2w1fLfOpyEPJ1Lv/lV9lsDZOnsHltol3tUKdLXpLhFiUY1xpo6u6y KMFG/268J0JS5hXTzOLsrzxAioakoHt4BTX0FDEOWDoNAlziOll2fk/hkZjIu56YCp2A d58tqd3Pwuj7gKxFo0c5DtHdu97WLfzPw9MgcZhPa3PtNuFypeztKLXBIB/NckOsXv1o 8iiWleLFY4oRDMEkvw+GZrAcoPLou5hIpM8z3p+hztdaG8Jp5LyO7liAsO5959Kt525g /w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2w41w145fy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Nov 2019 07:49:01 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xA77mqQA008876; Thu, 7 Nov 2019 07:49:00 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2w41w93xu2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Nov 2019 07:48:59 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xA77mt2T019768; Thu, 7 Nov 2019 07:48:56 GMT Received: from mwanda (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Nov 2019 23:48:55 -0800 Date: Thu, 7 Nov 2019 10:48:47 +0300 From: Dan Carpenter To: Philipp Reisner Cc: Lars Ellenberg , Jens Axboe , drbd-dev@tron.linbit.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] block: drbd: remove a stay unlock in __drbd_send_protocol() Message-ID: <20191107074847.GA11695@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9433 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1910280000 definitions=main-1911070078 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9433 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1910280000 definitions=main-1911070078 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are two callers of this function and they both unlock the mutex so this ends up being a double unlock. Fixes: 44ed167da748 ("drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf") Signed-off-by: Dan Carpenter --- Static analisys. Not tested. There is a comment about the lock next to the caller in drbd_nl.c that I didn't understand: drivers/block/drbd/drbd_nl.c 2509 crypto_free_shash(connection->integrity_tfm); 2510 connection->integrity_tfm = crypto.integrity_tfm; 2511 if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100) 2512 /* Do this without trying to take connection->data.mutex again. */ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What does this mean? We're already holding that lock. We took it near the start of the function. 2513 __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); 2514 2515 crypto_free_shash(connection->cram_hmac_tfm); 2516 connection->cram_hmac_tfm = crypto.cram_hmac_tfm; 2517 2518 mutex_unlock(&connection->resource->conf_update); 2519 mutex_unlock(&connection->data.mutex); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unlocked here. drivers/block/drbd/drbd_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 5b248763a672..a18155cdce41 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -786,7 +786,6 @@ int __drbd_send_protocol(struct drbd_connection *connection, enum drbd_packet cm if (nc->tentative && connection->agreed_pro_version < 92) { rcu_read_unlock(); - mutex_unlock(&sock->mutex); drbd_err(connection, "--dry-run is not supported by peer"); return -EOPNOTSUPP; } -- 2.20.1