Commit 2e501ac9 authored by Wenchao Hao's avatar Wenchao Hao Committed by Hao Zhang
Browse files

scsi: mpt3sas: Fix NULL pointer access in mpt3sas_transport_port_add()

stable inclusion
from stable-v5.10.176
commit 6f0c2f70d9929208d8427ec72c3ed91e2251e289
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8AGBT
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.10.y&id=6f0c2f70d9929208d8427ec72c3ed91e2251e289



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

[ Upstream commit d3c57724 ]

Port is allocated by sas_port_alloc_num() and rphy is allocated by either
sas_end_device_alloc() or sas_expander_alloc(), all of which may return
NULL. So we need to check the rphy to avoid possible NULL pointer access.

If sas_rphy_add() returned with failure, rphy is set to NULL. We would
access the rphy in the following lines which would also result NULL pointer
access.

Fixes: 78316e9d ("scsi: mpt3sas: Fix possible resource leaks in mpt3sas_transport_port_add()")
Signed-off-by: default avatarWenchao Hao <haowenchao2@huawei.com>
Link: https://lore.kernel.org/r/20230225100135.2109330-1-haowenchao2@huawei.com


Acked-by: default avatarSathya Prakash Veerichetty <sathya.prakash@broadcom.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 avatarHao Zhang <Hao.Zhang@windriver.com>
parent 3c6a5ba3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment