Commit d50ae624 authored by Jia-Ju Bai's avatar Jia-Ju Bai Committed by Wang Wensheng
Browse files

scsi: mpt3sas: Fix error return code of mpt3sas_base_attach()

stable inclusion
from stable-v4.19.184
commit 1e8efaf7e5c46657ebe8596c7ec234a1cb00c65e
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IACZL6
CVE: CVE-2024-40901

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

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

[ Upstream commit 3401ecf7 ]

When kzalloc() returns NULL, no error return code of mpt3sas_base_attach()
is assigned. To fix this bug, r is assigned with -ENOMEM in this case.

Link: https://lore.kernel.org/r/20210308035241.3288-1-baijiaju1990@gmail.com


Fixes: c696f7b8 ("scsi: mpt3sas: Implement device_remove_in_progress check in IOCTL path")
Reported-by: default avatarTOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWang Wensheng <wangwensheng4@huawei.com>
parent 7ad52b44
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -6627,14 +6627,18 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
		ioc->pend_os_device_add_sz++;
	ioc->pend_os_device_add = kzalloc(ioc->pend_os_device_add_sz,
	    GFP_KERNEL);
	if (!ioc->pend_os_device_add)
	if (!ioc->pend_os_device_add) {
		r = -ENOMEM;
		goto out_free_resources;
	}

	ioc->device_remove_in_progress_sz = ioc->pend_os_device_add_sz;
	ioc->device_remove_in_progress =
		kzalloc(ioc->device_remove_in_progress_sz, GFP_KERNEL);
	if (!ioc->device_remove_in_progress)
	if (!ioc->device_remove_in_progress) {
		r = -ENOMEM;
		goto out_free_resources;
	}

	ioc->fwfault_debug = mpt3sas_fwfault_debug;