Messages in this thread Patch in this message | | | Date | Tue, 3 Mar 2015 08:46:10 +0530 | From | Tapasweni Pathak <> | 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
| |