Skip to content

Commit bb44e15

Browse files
tomerbhtejun
authored andcommitted
sata_sx4: Check return code from pdc20621_i2c_read()
The variable spd0 might be used uninitialized when pdc20621_i2c_read() fails. This also generates a compilation warning with gcc 5.1. tj: use pr_err() Signed-off-by: Tomer Barletz <barletz@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 74a80d6 commit bb44e15

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/ata/sata_sx4.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,12 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host)
12381238
readl(mmio + PDC_SDRAM_CONTROL);
12391239

12401240
/* Turn on for ECC */
1241-
pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1242-
PDC_DIMM_SPD_TYPE, &spd0);
1241+
if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1242+
PDC_DIMM_SPD_TYPE, &spd0)) {
1243+
pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n",
1244+
PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
1245+
return 1;
1246+
}
12431247
if (spd0 == 0x02) {
12441248
data |= (0x01 << 16);
12451249
writel(data, mmio + PDC_SDRAM_CONTROL);
@@ -1380,8 +1384,12 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
13801384

13811385
/* ECC initiliazation. */
13821386

1383-
pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1384-
PDC_DIMM_SPD_TYPE, &spd0);
1387+
if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1388+
PDC_DIMM_SPD_TYPE, &spd0)) {
1389+
pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n",
1390+
PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
1391+
return 1;
1392+
}
13851393
if (spd0 == 0x02) {
13861394
void *buf;
13871395
VPRINTK("Start ECC initialization\n");

0 commit comments

Comments
 (0)