Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp392234rdb; Mon, 29 Jan 2024 05:41:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHt+p1somm6h4Ew4RfyX406RjLPs1gmga3Q6qK+9FCoQPJhb4WwIUTI/SQhFoAnWicYXfrf X-Received: by 2002:a05:6a00:2b55:b0:6dd:a2ea:6626 with SMTP id du21-20020a056a002b5500b006dda2ea6626mr2114047pfb.16.1706535693231; Mon, 29 Jan 2024 05:41:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706535693; cv=pass; d=google.com; s=arc-20160816; b=ExTYJqoup0/lSuHqdvIMPyp6Bi067Q8sOxwchHoIAAqws6jY2+f87l+Hgybwl4gNoO uGh6rHc8qOQiUMwJcikzfMbWBwXBF5+B6VRZE2RC39+xdgBn31Lio2nZ6Puju2YUDPxU +88lea3/1UVBnqmm2fLDFTuzNjdgGmgnx0Uv1a2hDL8j8tyo9MGfoV+jLlkaSAweRuGa 01pJ00h/CTPyQKwKRlaxLAacck0RzbC7d5hZVqPT7W4SkFt63+Bsg8DNwB7aszYV7iwk Y4UEMz4uT9WPa3eUL1mESamwI3FhVAliAs6GOFhZmRaAHjF4AuFbjo1zCC4/f9pHggmq A47A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=B5Ma2WgdBHrdt+ckeoyR+5EPIRUCO5bZvgrvESaMv9E=; fh=lZlfcyytvL5HUgt/LAffJCS/H/hDu5jDOLAkXLFqJcI=; b=OUKHJclG13bzKrgxOF0UvrGr3/jeE1Lyls+aoeJdUHTrzW4eZkig0tkHULhbLVcMCp OV/Xugrbv6haKWGeA8/oc+ofcFXoz4Vq7qZmU0g6CGDKaIfWQ6/I1coVgRfgTG2PURne TpRyvyPWXtSF4Jp1dKJfxCvLUT7XwBtQko3AORkAcefpAX68rfB3v8UPK6X0MXb9qIn1 /zqwAupdV7Yilig1LUBxAPHwHl4SUKNoqHPmoIEyqLmuFmC/1XcISbC5pc/Jz/XDzLGE n7Jr35ZHuLDnAKfo/iFW8HVXhHg5RESRCFY2zT0m577H/JzJEhirzVdxsii8eK4pYvyn a25Q== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-42793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42793-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d15-20020aa7868f000000b006ddc62897a4si5575778pfo.113.2024.01.29.05.41.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 05:41:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-42793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42793-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 969DAB25AE2 for ; Mon, 29 Jan 2024 13:26:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F0E4657A4; Mon, 29 Jan 2024 13:26:27 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75D1C651B4; Mon, 29 Jan 2024 13:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534786; cv=none; b=Re4AY5ciC5ze36bubPNhcuedc3qAbJ02OM+z5xLsoDfZLYqn49FIOgwPQIw+6u8TzvOeHA34PjyoN79w9U9x/qAqSLiW87mASrUxu4xLj0C6+D8d0t1kYw2mQA9LHkGV5myqaEtEdwintCK+1kFoAVkOhf3vI2LGVPmuKLwogNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706534786; c=relaxed/simple; bh=qmgmBSJn42YGU9RsT3APt7F3V8FEC8E68Drv0VWCPkI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SjkWmPpVxSGqMk/7HTtFdNMtT5Bk5dXGnmpwfeZRPKX0EUTQf9S+xV55Lfra/XMYfnoFIpox5oeSGelc0Ij4ku8nymyEa8b1frwSgPC1yxYxpdzP6+oMfjMzX+eSm7pDXJm3vUzqe+4Nfccb/H98D5MhXlwlQebFTmE0Xheh07Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TNpwQ1qnBz4f3lgB; Mon, 29 Jan 2024 21:26:14 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id B067B1A0272; Mon, 29 Jan 2024 21:26:20 +0800 (CST) Received: from [10.174.179.247] (unknown [10.174.179.247]) by APP2 (Coremail) with SMTP id Syh0CgAnmAt6p7dlIwuSCQ--.6189S3; Mon, 29 Jan 2024 21:26:20 +0800 (CST) Message-ID: Date: Mon, 29 Jan 2024 21:26:18 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] scsi: sd: unregister device if device_add_disk() failed in sd_probe() To: linan666@huaweicloud.com, jejb@linux.ibm.com, martin.petersen@oracle.com, mcgrof@kernel.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com References: <20231208082335.1754205-1-linan666@huaweicloud.com> From: Li Nan In-Reply-To: <20231208082335.1754205-1-linan666@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:Syh0CgAnmAt6p7dlIwuSCQ--.6189S3 X-Coremail-Antispam: 1UD129KBjvdXoWrKryxKr45ArWUGF1kKFyfWFg_yoWDWwb_Cw 42v397Xr1rCw1Iyr1fAr1avrW0vFsFq3yrCF4jqr9avayfX3yv9F9Y9ryYvr4UGF4xuw1j yr1UXr4Fkr4kGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbS8FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIF xwACI402YVCY1x02628vn2kIc2xKxwCYjI0SjxkI62AI1cAE67vIY487MxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUQZ23UUUUU= X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ friendly ping ... 在 2023/12/8 16:23, linan666@huaweicloud.com 写道: > From: Li Nan > > "if device_add() succeeds, you should call device_del() when you want to > get rid of it." > > In sd_probe(), device_add_disk() fails when device_add() has already > succeeded, so change put_device() to device_unregister() to ensure device > resources are released. > > Fixes: 2a7a891f4c40 ("scsi: sd: Add error handling support for add_disk()") > Signed-off-by: Li Nan > --- > drivers/scsi/sd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c > index 542a4bbb21bc..d81cbeee06eb 100644 > --- a/drivers/scsi/sd.c > +++ b/drivers/scsi/sd.c > @@ -3736,7 +3736,7 @@ static int sd_probe(struct device *dev) > > error = device_add_disk(dev, gd, NULL); > if (error) { > - put_device(&sdkp->disk_dev); > + device_unregister(&sdkp->disk_dev); > put_disk(gd); > goto out; > } -- Thanks, Nan