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()
Unified · Split
| @@ -223,10 +223,16 @@ static int pxa_ata_probe(struct platform_device *pdev) · 222 unmodified lines | ||
| 223 | 223 | |
| 224 | 224 | ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, cmd_res->start, |
| 225 | 225 | resource_size(cmd_res)); |
| 226 | + if (!ap->ioaddr.cmd_addr) | |
| 227 | + return -ENOMEM; | |
| 226 | 228 | ap->ioaddr.ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start, |
| 227 | 229 | resource_size(ctl_res)); |
| 230 | + if (!ap->ioaddr.ctl_addr) | |
| 231 | + return -ENOMEM; | |
| 228 | 232 | ap->ioaddr.bmdma_addr = devm_ioremap(&pdev->dev, dma_res->start, |
| 229 | 233 | resource_size(dma_res)); |
| 234 | + if (!ap->ioaddr.bmdma_addr) | |
| 235 | + return -ENOMEM; | |
| 230 | 236 | |
| 231 | 237 | /* |
| 232 | 238 | * Adjust register offsets |
| @@ -1117,9 +1117,14 @@ static int pdc20621_prog_dimm0(struct ata_host *host) · 1116 unmodified lines | ||
| 1117 | 1117 | mmio += PDC_CHIP0_OFS; |
| 1118 | 1118 | |
| 1119 | 1119 | 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 | + } | |
| 1123 | 1128 | |
| 1124 | 1129 | data |= (spd0[4] - 8) | ((spd0[21] != 0) << 3) | ((spd0[3]-11) << 4); |
| 1125 | 1130 | data |= ((spd0[17] / 4) << 6) | ((spd0[5] / 2) << 7) | |
| @@ -1284,6 +1289,8 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host) · 158 unmodified lines | ||
| 1284 | 1289 | |
| 1285 | 1290 | /* Programming DIMM0 Module Control Register (index_CID0:80h) */ |
| 1286 | 1291 | size = pdc20621_prog_dimm0(host); |
| 1292 | + if (size < 0) | |
| 1293 | + return size; | |
| 1287 | 1294 | dev_dbg(host->dev, "Local DIMM Size = %dMB\n", size); |
| 1288 | 1295 | |
| 1289 | 1296 | /* Programming DIMM Module Global Control Register (index_CID0:88h) */ |