summaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorSergey Shtylyov <s.shtylyov@omp.ru>2022-05-21 23:34:10 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-22 14:21:56 +0200
commitff128fbea720bf763fa345680dda5f050bc24a47 (patch)
tree1714e597be0d0b729af4b615a133221a40a368e5 /drivers/ata
parent4a0d2797918c87e30193167a2da6a743aa2cddc1 (diff)
downloadlinux-stable-ff128fbea720bf763fa345680dda5f050bc24a47.tar.gz
linux-stable-ff128fbea720bf763fa345680dda5f050bc24a47.tar.bz2
linux-stable-ff128fbea720bf763fa345680dda5f050bc24a47.zip
ata: libata-core: fix NULL pointer deref in ata_host_alloc_pinfo()
[ Upstream commit bf476fe22aa1851bab4728e0c49025a6a0bea307 ] In an unlikely (and probably wrong?) case that the 'ppi' parameter of ata_host_alloc_pinfo() points to an array starting with a NULL pointer, there's going to be a kernel oops as the 'pi' local variable won't get reassigned from the initial value of NULL. Initialize 'pi' instead to '&ata_dummy_port_info' to fix the possible kernel oops for good... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index a0343b7c9add..413faa9330b2 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5500,7 +5500,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev,
const struct ata_port_info * const * ppi,
int n_ports)
{
- const struct ata_port_info *pi;
+ const struct ata_port_info *pi = &ata_dummy_port_info;
struct ata_host *host;
int i, j;
@@ -5508,7 +5508,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev,
if (!host)
return NULL;
- for (i = 0, j = 0, pi = NULL; i < host->n_ports; i++) {
+ for (i = 0, j = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];
if (ppi[j])