Commit 9f17b21a authored by Zhong Jinghua's avatar Zhong Jinghua Committed by Li Lingfeng
Browse files

scsi: scsi_device_gets returns failure when the module is NULL.

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7YWV4


CVE: NA

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

when module is NULL, try_module_get return true.
But it would be better to return failure in scsi_device_get.

Signed-off-by: default avatarZhong Jinghua <zhongjinghua@huawei.com>
Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
parent 8c17b6e2
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -529,11 +529,15 @@ EXPORT_SYMBOL(scsi_report_opcode);
 */
int scsi_device_get(struct scsi_device *sdev)
{
	struct module *module;

	if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL)
		goto fail;
	if (!get_device(&sdev->sdev_gendev))
		goto fail;
	if (!try_module_get(sdev->host->hostt->module))

	module = sdev->host->hostt->module;
	if (!module || !try_module_get(module))
		goto fail_put_device;
	return 0;