]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
scsi: mpt3sas: Fix NULL pointer access in mpt3sas_transport_port_add()
authorWenchao Hao <haowenchao2@huawei.com>
Sat, 25 Feb 2023 10:01:36 +0000 (18:01 +0800)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Wed, 17 May 2023 11:33:13 +0000 (13:33 +0200)
commit44c0da13ad4961a5a47f2d2ff27f56712bdbadd4
tree886ba306031ceb5c1df1729ddd1773133e1570ad
parent9bc2d9c8d46a76a44b593bb4d01479ebf177de38
scsi: mpt3sas: Fix NULL pointer access in mpt3sas_transport_port_add()

BugLink: https://bugs.launchpad.net/bugs/2016876
[ Upstream commit d3c57724f1569311e4b81e98fad0931028b9bdcd ]

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: 78316e9dfc24 ("scsi: mpt3sas: Fix possible resource leaks in mpt3sas_transport_port_add()")
Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
Link: https://lore.kernel.org/r/20230225100135.2109330-1-haowenchao2@huawei.com
Acked-by: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/scsi/mpt3sas/mpt3sas_transport.c