lkml.org 
[lkml]   [2015]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH v2] drivers: media: i2c : s5c73m3: Fix null dereference
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@gmail.com>
---
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


\
 
 \ /
  Last update: 2015-03-03 04:41    [W:0.295 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site