Re: [PATCH] scsi: mpt3sas: fix NULL pointer access in mpt3sas_transport_port_add()

From: Martin K. Petersen
Date: Mon Mar 06 2023 - 20:42:41 EST



Ranjan/Sreekanth,

> port is allocated by sas_port_alloc_num() and rphy is allocated by
> sas_end_device_alloc() or sas_expander_alloc() which may return NULL,
> so we need to check the rphy to avoid possible NULL pointer access.
>
> If sas_rphy_add() called with failure rphy is set to NULL, we would
> access the rphy in next lines which would also result NULL pointer
> access.
>
> Fix commit 78316e9dfc24 ("scsi: mpt3sas: Fix possible resource leaks
> in mpt3sas_transport_port_add()")

Please review!

--
Martin K. Petersen Oracle Linux Engineering