Skip to content

Commit 2f3e5ef

Browse files
committed
Merge tag 'ata-6.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux
Pull ata fixes from Damien Le Moal: - Fix missing error checks during controller probe in the sata_sx4 driver (Wentao) - Fix missing error checks during controller probe in the pata_pxa driver (Henry) * tag 'ata-6.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: ata: sata_sx4: Add error handling in pdc20621_i2c_read() ata: pata_pxa: Fix potential NULL pointer dereference in pxa_ata_probe()
2 parents ff88562 + 8d46a27 commit 2f3e5ef

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

drivers/ata/pata_pxa.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,16 @@ static int pxa_ata_probe(struct platform_device *pdev)
223223

224224
ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, cmd_res->start,
225225
resource_size(cmd_res));
226+
if (!ap->ioaddr.cmd_addr)
227+
return -ENOMEM;
226228
ap->ioaddr.ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start,
227229
resource_size(ctl_res));
230+
if (!ap->ioaddr.ctl_addr)
231+
return -ENOMEM;
228232
ap->ioaddr.bmdma_addr = devm_ioremap(&pdev->dev, dma_res->start,
229233
resource_size(dma_res));
234+
if (!ap->ioaddr.bmdma_addr)
235+
return -ENOMEM;
230236

231237
/*
232238
* Adjust register offsets

drivers/ata/sata_sx4.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,14 @@ static int pdc20621_prog_dimm0(struct ata_host *host)
11171117
mmio += PDC_CHIP0_OFS;
11181118

11191119
for (i = 0; i < ARRAY_SIZE(pdc_i2c_read_data); i++)
1120-
pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1121-
pdc_i2c_read_data[i].reg,
1122-
&spd0[pdc_i2c_read_data[i].ofs]);
1120+
if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1121+
pdc_i2c_read_data[i].reg,
1122+
&spd0[pdc_i2c_read_data[i].ofs])) {
1123+
dev_err(host->dev,
1124+
"Failed in i2c read at index %d: device=%#x, reg=%#x\n",
1125+
i, PDC_DIMM0_SPD_DEV_ADDRESS, pdc_i2c_read_data[i].reg);
1126+
return -EIO;
1127+
}
11231128

11241129
data |= (spd0[4] - 8) | ((spd0[21] != 0) << 3) | ((spd0[3]-11) << 4);
11251130
data |= ((spd0[17] / 4) << 6) | ((spd0[5] / 2) << 7) |
@@ -1284,6 +1289,8 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
12841289

12851290
/* Programming DIMM0 Module Control Register (index_CID0:80h) */
12861291
size = pdc20621_prog_dimm0(host);
1292+
if (size < 0)
1293+
return size;
12871294
dev_dbg(host->dev, "Local DIMM Size = %dMB\n", size);
12881295

12891296
/* Programming DIMM Module Global Control Register (index_CID0:88h) */

0 commit comments

Comments
 (0)