提交 95a53192 编写于 作者: M Ming Lei 提交者: Zheng Zengkai

scsi: sd: Free scsi_disk device via put_device()

stable inclusion
from stable-5.10.72
commit 60df9f55562a57173a11b6c7011eee40dfa48157
bugzilla: 182982 https://gitee.com/openeuler/kernel/issues/I4I3L1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=60df9f55562a57173a11b6c7011eee40dfa48157

--------------------------------

[ Upstream commit 265dfe8e ]

After a device is initialized via device_initialize() it should be freed
via put_device(). sd_probe() currently gets this wrong, fix it up.

Link: https://lore.kernel.org/r/20210906090112.531442-1-ming.lei@redhat.comReviewed-by: NBart Van Assche <bvanassche@acm.org>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NMing Lei <ming.lei@redhat.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 83856aac
...@@ -3443,15 +3443,16 @@ static int sd_probe(struct device *dev) ...@@ -3443,15 +3443,16 @@ static int sd_probe(struct device *dev)
} }
device_initialize(&sdkp->dev); device_initialize(&sdkp->dev);
sdkp->dev.parent = dev; sdkp->dev.parent = get_device(dev);
sdkp->dev.class = &sd_disk_class; sdkp->dev.class = &sd_disk_class;
dev_set_name(&sdkp->dev, "%s", dev_name(dev)); dev_set_name(&sdkp->dev, "%s", dev_name(dev));
error = device_add(&sdkp->dev); error = device_add(&sdkp->dev);
if (error) if (error) {
goto out_free_index; put_device(&sdkp->dev);
goto out;
}
get_device(dev);
dev_set_drvdata(dev, sdkp); dev_set_drvdata(dev, sdkp);
gd->major = sd_major((index & 0xf0) >> 4); gd->major = sd_major((index & 0xf0) >> 4);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册