From: Krzysztof Oledzki Date: Tue, 4 Mar 2008 22:56:23 +0000 (-0800) Subject: [SCSI] mpt fusion: don't oops if NumPhys==0 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=51f39eae14b4874618e73281c236e3a1c1572d4d;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git [SCSI] mpt fusion: don't oops if NumPhys==0 Don't oops if NumPhys==0, instead return -ENODEV. This patch fixes http://bugzilla.kernel.org/show_bug.cgi?id=9909 Signed-off-by: Krzysztof Piotr Oledzki Acked-by: Eric Moore Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index f77b329f6923..78734e25edd5 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -1701,6 +1701,11 @@ mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info, if (error) goto out_free_consistent; + if (!buffer->NumPhys) { + error = -ENODEV; + goto out_free_consistent; + } + /* save config data */ port_info->num_phys = buffer->NumPhys; port_info->phy_info = kcalloc(port_info->num_phys,