Staging: Media: Lirc - Fix possible ERR_PTR() dereferencing.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is of course wrong to call kfree() if memdup_user() fails,
no memory was allocated and the error in the error-valued pointer
should be returned.

Reviewed-by: Ravikant Sharma <ravikant.s2@xxxxxxxxxxx>
Signed-off-by: Shailendra Verma <shailendra.v@xxxxxxxxxxx>
---
 drivers/staging/media/lirc/lirc_imon.c  | 7 ++-----
 drivers/staging/media/lirc/lirc_sasem.c | 7 ++-----
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
index 534b810..c21591b 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -409,11 +409,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
 	}
 
 	data_buf = memdup_user(buf, n_bytes);
-	if (IS_ERR(data_buf)) {
-		retval = PTR_ERR(data_buf);
-		data_buf = NULL;
-		goto exit;
-	}
+	if (IS_ERR(data_buf))
+		return PTR_ERR(data_buf);
 
 	memcpy(context->tx.data_buf, data_buf, n_bytes);
 
diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c
index f2dca69..ba1ee86 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -387,11 +387,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
 	}
 
 	data_buf = memdup_user(buf, n_bytes);
-	if (IS_ERR(data_buf)) {
-		retval = PTR_ERR(data_buf);
-		data_buf = NULL;
-		goto exit;
-	}
+	if (IS_ERR(data_buf))
+		return PTR_ERR(data_buf);
 
 	memcpy(context->tx.data_buf, data_buf, n_bytes);
 
-- 
1.9.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux