From patchwork Mon Aug 12 12:31:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sun Ke X-Patchwork-Id: 11089777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65131912 for ; Mon, 12 Aug 2019 12:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56D9427F91 for ; Mon, 12 Aug 2019 12:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B37527F93; Mon, 12 Aug 2019 12:25:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3A0D27FA8 for ; Mon, 12 Aug 2019 12:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728482AbfHLMZN (ORCPT ); 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 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Mike Christie --- 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),