Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2703431pxb; Sun, 31 Oct 2021 23:20:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqaYCbUbvL+m/ss/ykHfGXXRRN2I61MhfT4vEw7fcu1oSc4OP1GAw72TTPKSAOMRAR7YH8 X-Received: by 2002:a05:6e02:194e:: with SMTP id x14mr18761107ilu.161.1635747606663; Sun, 31 Oct 2021 23:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635747606; cv=none; d=google.com; s=arc-20160816; b=PD2kDqQjKumNWyW5AoL3w7faw44w8iP5EnrSFnxkC40naEYH6raBC8/lBMhPlcU2L/ P+qfGasop9lTpyXIqYvjTji+cNp2qYk7DKYyCJadcBmf2H+SDFHqIu1yGMoUyap2unz1 xldGjQ43dClM6A2B1VHPx8C/5YEKasNTUcV2Bo0MLazOH92ojFrYAJPgciPNfNEcy9hX jeIBjcO2X2pT2qBPhVU1RMjPkBaXAhSgdKDhGmUtPzA7jh/80+MoaGgVRuiRpyKeSa99 B70ZUIGmVfVIROlF2+Pp8HxFHOzQcjcUZD9EX5pNLIXs6vUhSrJckdx3Fmcvc4NTeJD9 ABWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yc5eQYfXouaYZNwawsCcXk3+AbT0YQgCaNDx6HGprcM=; b=Y6bzci2P/7hRO0ufFQFAA4BBk0m4ExUSzYpbf/yhymUWk3mukTD/ekDK+HG2xadWbv 1+OBUQ5ik2v/Ee5juM/yQ5O4w0cxOtxb1B4PrdP+iR77lrWlpHmk+e/s/Y2SxYLbCAi/ d0N00Z2hZJFOLaSRv0f9Y4ljapobLQxx7sMypJTFJIhatM12s783DNjOVm1ZVpiGZHac tqXTzhkbPSRFgM3SpnTk4uFDKSzL0OFlZv4UBaFPsRScI8TDJWyLDNzXRdJJFFu+Nuuq RZ8yaBKqN8ArMYfW1yjhXtS69vRQxM7nIv2AYcLMo8f1Q1qL8yVraeL+UTHW9moxNz+z dFfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si17748037ilu.164.2021.10.31.23.19.55; Sun, 31 Oct 2021 23:20:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbhKAGUK (ORCPT + 99 others); Mon, 1 Nov 2021 02:20:10 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:15323 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbhKAGUA (ORCPT ); Mon, 1 Nov 2021 02:20:00 -0400 Received: from dggeme754-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HjN9M2nQyz90d6; Mon, 1 Nov 2021 14:17:11 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme754-chm.china.huawei.com (10.3.19.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Mon, 1 Nov 2021 14:17:08 +0800 From: Ye Bin To: , , , CC: , Ye Bin Subject: [PATCH -next v3 1/2] nbd: Fix incorrect error handle when first_minor big than '0xff' in nbd_dev_add Date: Mon, 1 Nov 2021 14:29:55 +0800 Message-ID: <20211101062956.791573-2-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211101062956.791573-1-yebin10@huawei.com> References: <20211101062956.791573-1-yebin10@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggeme754-chm.china.huawei.com (10.3.19.100) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If first_minor big than '0xff' goto out_free_idr label, this will miss cleanup disk. Fixes: b1a811633f73 ("block: nbd: add sanity check for first_minor") Signed-off-by: Ye Bin --- drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index b47b2a87ae8f..096883ab9b76 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1809,7 +1809,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) disk->first_minor = index << part_shift; if (disk->first_minor > 0xff) { err = -EINVAL; - goto out_free_idr; + goto out_err_disk; } disk->minors = 1 << part_shift; -- 2.31.1