Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1199202

[PATCH] sata_sx4: Check return code from pdc20621_i2c_read()

From Tomer Barletz <barletz@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] sata_sx4: Check return code from pdc20621_i2c_read()
Date 2015-08-03 21:20 +0200
Message-ID <pTtrb-3P6-3@gated-at.bofh.it> (permalink)
References <pTt7R-3cQ-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The variable spd0 might be used uninitialized when pdc20621_i2c_read()
fails.
This also generates a compilation warning with gcc 5.1.

Signed-off-by: Tomer Barletz <barletz@gmail.com>
---
 drivers/ata/sata_sx4.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index 3a18a8a..b482c25 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -1238,8 +1238,12 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host)
 	readl(mmio + PDC_SDRAM_CONTROL);
 
 	/* Turn on for ECC */
-	pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
-			  PDC_DIMM_SPD_TYPE, &spd0);
+	if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
+			       PDC_DIMM_SPD_TYPE, &spd0)) {
+		printk(KERN_ERR "Failed in i2c read: device=%#x, subaddr=%#x\n",
+		       PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
+		return 1;
+	}
 	if (spd0 == 0x02) {
 		data |= (0x01 << 16);
 		writel(data, mmio + PDC_SDRAM_CONTROL);
@@ -1380,8 +1384,12 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
 
 	/* ECC initiliazation. */
 
-	pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
-			  PDC_DIMM_SPD_TYPE, &spd0);
+	if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
+			       PDC_DIMM_SPD_TYPE, &spd0)) {
+		printk(KERN_ERR "Failed in i2c read: device=%#x, subaddr=%#x\n",
+		       PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
+		return 1;
+	}
 	if (spd0 == 0x02) {
 		void *buf;
 		VPRINTK("Start ECC initialization\n");
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] Check return code from pdc20621_i2c_read() Tomer Barletz <barletz@gmail.com> - 2015-08-02 12:20 +0200
  Re: [PATCH] Check return code from pdc20621_i2c_read() Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-08-02 13:10 +0200
    Re: [PATCH] Check return code from pdc20621_i2c_read() Joe Perches <joe@perches.com> - 2015-08-02 20:10 +0200
    Re: [PATCH] Check return code from pdc20621_i2c_read() Tomer Barletz <barletz@gmail.com> - 2015-08-02 20:00 +0200
      Re: [PATCH] Check return code from pdc20621_i2c_read() Joe Perches <joe@perches.com> - 2015-08-02 22:30 +0200
      Re: [PATCH] Check return code from pdc20621_i2c_read() Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-08-03 17:50 +0200
        Re: [PATCH] Check return code from pdc20621_i2c_read() Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-08-03 18:00 +0200
          [PATCH] sata_sx4: Check return code from pdc20621_i2c_read() Tomer Barletz <barletz@gmail.com> - 2015-08-03 20:50 +0200
            Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read() Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-08-03 21:00 +0200
              Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read() Joe Perches <joe@perches.com> - 2015-08-03 21:10 +0200
              Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read() Tomer Barletz <barletz@gmail.com> - 2015-08-03 21:10 +0200
                Re: [PATCH] sata_sx4: Check return code from pdc20621_i2c_read() Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-08-03 21:20 +0200
              [PATCH] sata_sx4: Check return code from pdc20621_i2c_read() Tomer Barletz <barletz@gmail.com> - 2015-08-03 21:20 +0200

csiph-web