Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3724284ybl; Mon, 12 Aug 2019 05:26:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQZo8o9FAWyeiRmrQ2IkLfF/vGr1NpTdqIa0galHFyto6812x6HmFjFYMrQsbKbGS3vew2 X-Received: by 2002:a63:1d2:: with SMTP id 201mr30821707pgb.307.1565612789853; Mon, 12 Aug 2019 05:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565612789; cv=none; d=google.com; s=arc-20160816; b=P/YQWRi8gF5y+bNkiSDCDzcRq7GANahNZkQdgQIBiussi10xIn/fXMZJ194Wm74l1U 8c8B6UFw9JnPRayXkAu9fmSFEBohXako/2J+StyfuGIJMFpTWAXNa5+n3HPr+vfPE/Qr ffqbEuL0eEnkln9MxS1clKyJcwY/OqZLVQTpig4YzSolXH69ST9JU7Nnj3QEOBVwJegx KYU0iazWTQwxBQ8bHjuIa7tov4M5lb9fU1ABaBKpUGxC1IavUKUoy3ff6uTz3LURcZ3a BEo1/Ox6WhJoIjHgxAbRWVOZTTPgfnMepQHdd351yKb/sB99GT1Tpc8f338tLbQs3vdl 63rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:to :from; bh=L4aJV/Q2PKBps9/eQZMX6xN6Izq48AfrKefP65z7mgE=; b=G1KEMj4G1NUcNxElCDR1G/hMjra0l8xz19/cWrVFCbiR7AzeE03SUp7lINfMF28tjR frkVe8tqHSWS0N4kaTs3BhXuQ/EcOoOnrguVYkFzR7U0Rh1SJgZj+dFfAByd+CpTri4p t/Z+KCKYwQ6ZzWGohKGl94+TD6hJs0j44vnhRxXX6gYxK4fAyYLSJY0/kkC7o66IowFc Jwit1PVfQFBm9jgMFJWwYmPY3pVWPLkTVBWo4NUPAnc8EN4iLohGlYIaVA7ve5fQ9Y40 OiCRdnztG4PH+LODOP7Va32D3h83YIz1M6AbYoAHxDq89dRtTTIoKfAJZgonj7p1JejZ a4JA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v189si61804155pgd.289.2019.08.12.05.26.14; Mon, 12 Aug 2019 05:26:29 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728795AbfHLMZN (ORCPT + 99 others); Mon, 12 Aug 2019 08:25:13 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4660 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728464AbfHLMZM (ORCPT ); Mon, 12 Aug 2019 08:25:12 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3FD46459B3490B51E00F; Mon, 12 Aug 2019 20:25:10 +0800 (CST) Received: from RH5885H-V3.huawei.com (10.90.53.225) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 12 Aug 2019 20:25:03 +0800 From: Sun Ke To: , , , , , Subject: [PATCH] nbd: add a missed nbd_config_put() in nbd_xmit_timeout() Date: Mon, 12 Aug 2019 20:31:26 +0800 Message-ID: <1565613086-13776-1-git-send-email-sunke32@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When try to get the lock failed, before return, execute the nbd_config_put() to decrease the nbd->config_refs. If the nbd->config_refs is added but not decreased. Then will not execute nbd_clear_sock() in nbd_config_put(). bd->task_setup will not be cleared away. Finally, print"Device being setup by another task" in nbd_add_sock() and nbd device can not be reused. Fixes: 8f3ea35929a0 ("nbd: handle unexpected replies better") Signed-off-by: Sun Ke --- drivers/block/nbd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index e21d2de..a69a90a 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -357,8 +357,10 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, } config = nbd->config; - if (!mutex_trylock(&cmd->lock)) + if (!mutex_trylock(&cmd->lock)) { + nbd_config_put(nbd); return BLK_EH_RESET_TIMER; + } if (config->num_connections > 1) { dev_err_ratelimited(nbd_to_dev(nbd), -- 2.7.4