ata: ahci_xgene: dereferencing uninitialized pointer in probe
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 10 Mar 2016 07:45:32 +0000 (10:45 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 May 2016 09:21:10 +0000 (11:21 +0200)
commit 8134233e8d346aaa1c929dc510e75482ae318bce upstream.

If the call to acpi_get_object_info() fails then "info" hasn't been
initialized.  In that situation, we already know that "version" should
be XGENE_AHCI_V1 so we don't actually need to dereference "info".

Fixes: c9802a4be661 ('ata: ahci_xgene: Add AHCI Support for 2nd HW version of APM X-Gene SoC AHCI SATA Host controller.')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/ata/ahci_xgene.c

index e2c6d9e0c5ac5ce5ce389b0ae1b0597ae979ee8b..e916bff6cee871fa69ac1107e7bf13f12b0ebdef 100644 (file)
@@ -739,9 +739,9 @@ static int xgene_ahci_probe(struct platform_device *pdev)
                                dev_warn(&pdev->dev, "%s: Error reading device info. Assume version1\n",
                                        __func__);
                                version = XGENE_AHCI_V1;
-                       }
-                       if (info->valid & ACPI_VALID_CID)
+                       } else if (info->valid & ACPI_VALID_CID) {
                                version = XGENE_AHCI_V2;
+                       }
                }
        }
 #endif