提交 2c189321 编写于 作者: W Wei Fang 提交者: Xie XiuQi

scsi: fix failing unload of a LLDD module

euler inclusion
category: bugfix
bugzilla: 8990
CVE: NA

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

This reverts part of commit cff549e4 ("scsi: proper state checking
and module refcount handling in scsi_device_get").

scsi_device_get() will fail in a module exit route, thus device
can't be removed.
Turn try_module_get() into __module_get() to make sure scsi device
will be removed normally.
Signed-off-by: NWei Fang <fangwei1@huawei.com>
Signed-off-by: NHanjun Guo <guohanjun@huawei.com>
[yan: cherry-picked from kernel-4.1 f94b5b901110]
Signed-off-by: NJason Yan <yanaijie@huawei.com>
Reviewed-by: Nzhengbin <zhengbin13@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 43392d05
......@@ -544,9 +544,6 @@ EXPORT_SYMBOL(scsi_report_opcode);
* Description: Gets a reference to the scsi_device and increments the use count
* of the underlying LLDD module. You must hold host_lock of the
* parent Scsi_Host or already have a reference when calling this.
*
* This will fail if a device is deleted or cancelled, or when the LLD module
* is in the process of being unloaded.
*/
int scsi_device_get(struct scsi_device *sdev)
{
......@@ -554,12 +551,12 @@ int scsi_device_get(struct scsi_device *sdev)
goto fail;
if (!get_device(&sdev->sdev_gendev))
goto fail;
if (!try_module_get(sdev->host->hostt->module))
goto fail_put_device;
/* We can fail try_module_get if we're doing SCSI operations
* from module exit (like cache flush)
*/
__module_get(sdev->host->hostt->module);
return 0;
fail_put_device:
put_device(&sdev->sdev_gendev);
fail:
return -ENXIO;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册