Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp223664rdb; Thu, 22 Feb 2024 01:24:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVjEf54si3t0sTineMPwyj/ppsUH/8SH1AcASV9k8yXF4Q78q6hU4YDx8yTdxnPfIZpf3AVe1h5PsdBFRvKA8JVNwPDWgsTMvUc8hN5tg== X-Google-Smtp-Source: AGHT+IGcCINCD/FX7xUFtRj8BIkXx9wYX/gAg/7OJhb0kqzBR9dpa/6GnN0/pgG1x2Nu90lycvqh X-Received: by 2002:a17:906:a3d8:b0:a3e:cd8d:39c3 with SMTP id ca24-20020a170906a3d800b00a3ecd8d39c3mr1595158ejb.38.1708593877482; Thu, 22 Feb 2024 01:24:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708593877; cv=pass; d=google.com; s=arc-20160816; b=ZBqJZV+cckQ5ABs+1yBW1tRMQ0+ZkXa3BZazdRVGJ/VZco2zQWPeizJVzD4dhbVftl Kv5BGOvom8IFJzDBYWs65hU6iaGqEdyC4cRvdYl8ll+5XbzdnkYYzV5YT9vGqTiE8fE+ zdGS4/rsU+vzDFuz5EwG9ke3zJFHo7q1Awhn8NnjDPoewf8+qrZFRv27PFg2eEekcaQd AiOCXuO0GP7aIwu3yVBJDM8jl/v92iPVhKrixX2ItYkf3rbKpkKgxIP/DbAr4iC2j1jh niOs5jZdcaCDDyu1seUd0zQboETYAeD4CyYB/UsK6312tUjBfGxRn7CdadaP55Ng2LSc Lwvg== 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=VzibzfEaJLMkHprvY/CAnZRzFZ/GVjbtfO3XlYQhF0A=; fh=sqxu7N+g0yl+PV4G7BnG3ijjgwmGz9c4xdrsUdf8SnM=; b=A/GLRIR7FBnM3HqXaQnWoo024qLIqcUfwoIaXgwa9EE0dykmJJVs3uqjMNu43QEme1 Si0iH6DOYxWuwjzoBO8S/6lvoemfv+rwEHK5A0L1R+/J9HORsJKh9rKBX7Vfh7JCjR6a +EZyFowZC7lMdNTA6FzpqFJjRkmd4eNwWorlhFqZqHjrUhsxPShc4Ju2KjQDVNfiUKae qPaY44eZtFlfgNITbydDDU36aC4rEiHKR1jRouIQbYAPgBIlJBuLuN7FbBvVytYpWuMH bcm4dzN2TVYx+jA/8pYdUhzTylbQqWMUvP6CI+OztJO+/xIOwrwhhKU+J0jBwfnMJD/S jPqg==; dara=google.com 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-76213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76213-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hs34-20020a1709073ea200b00a3f10df5693si1973462ejc.587.2024.02.22.01.24.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 01:24:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-76213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76213-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 40A151F25977 for ; Thu, 22 Feb 2024 09:24:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E75C9376F2; Thu, 22 Feb 2024 09:24:26 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [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 5C8DB2BB09; Thu, 22 Feb 2024 09:24: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=1708593866; cv=none; b=ju686H+q/UbCzK0O4IVvgY61PfNbzbZVHJZJoSWeOeZpyPBUUFDhQz7oDamGXO23S7t76pQmOiVPuhkr5gE346iawZrxdsVGTWux5mKPGLG2rwtZ0If7CFkivxq+m9OOl8znx1RrFzIBKHLX7GA2N2AW48JAh//aHYa1SFjTEdw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708593866; c=relaxed/simple; bh=Yqq/aNPUZed2Oe5vM66rRJzixSD3hRXsrZvbY3LmYxI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZJGLBe83tcEoCP8yRzlO5w1MKOpk+sEMQIyOjFuBYZ69U1l67f470cREG6GMOxnLcpd7rbd++AyW/7a8tX+///fE+Q8vmpuFYggr8OhnMd+/Gkwn4zWuJUDYJ4nXYqLc1hqEMzM+4qYiEJPK9/GcUnwWWpvGJYOH+dAE9JTKEBg= 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TgSQ95XpMz4f3kpQ; Thu, 22 Feb 2024 17:24:17 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id F39D21A0172; Thu, 22 Feb 2024 17:24:20 +0800 (CST) Received: from [10.174.179.247] (unknown [10.174.179.247]) by APP2 (Coremail) with SMTP id Syh0CgAXOQzBEtdlquR_Ew--.59051S3; Thu, 22 Feb 2024 17:24:20 +0800 (CST) Message-ID: <772d4058-aef0-0b06-068c-f33636fac01e@huaweicloud.com> Date: Thu, 22 Feb 2024 17:24:17 +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, 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:Syh0CgAXOQzBEtdlquR_Ew--.59051S3 X-Coremail-Antispam: 1UD129KBjvdXoWrKryxKr45ArWUGF1kKFyfWFg_yoWDWwb_Cw 42v397Xr1rCw1Iyr1fAr1avrW0vFsFq3yrCF4jqr9avayfX3yv9F9Y9ryYvr4UGF4xuw1j yr1UXr4Fkr4kGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbSxFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIF xwACI402YVCY1x02628vn2kIc2xKxwCYjI0SjxkI62AI1cAE67vIY487MxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAI w20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUOlksUUUUU 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