[PATCH v2] drivers: media: i2c : s5c73m3: Fix null dereference
From: Tapasweni Pathak
Date: Mon Mar 02 2015 - 22:16:23 EST
Replace dev_err statement which dereferences a null with pr_err_once.
Move if(!spi_dev) above if(dir...) block.
Found using Coccinelle.
Signed-off-by: Tapasweni Pathak <tapaswenipathak@xxxxxxxxx>
---
Changes since v1:
Replace pr_err with pr_err_once.
Move if(!spi_dev).
Reword commit message.
Reword subject.
drivers/media/i2c/s5c73m3/s5c73m3-spi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-spi.c b/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
index f60b265..376b78f 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
@@ -46,16 +46,16 @@ static int spi_xmit(struct spi_device *spi_dev, void *addr, const int len,
.len = len,
};
+ if(!spi_dev) {
+ pr_err_once("SPI device is unintialized\n");
+ return -ENODEV;
+ }
+
if (dir == SPI_DIR_TX)
xfer.tx_buf = addr;
else
xfer.rx_buf = addr;
- if (spi_dev == NULL) {
- dev_err(&spi_dev->dev, "SPI device is uninitialized\n");
- return -ENODEV;
- }
-
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/