* Staging: Media: Lirc - Fix possible ERR_PTR() dereferencing.
@ 2016-09-20 6:51 Shailendra Verma
2016-09-20 8:45 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Shailendra Verma @ 2016-09-20 6:51 UTC (permalink / raw)
To: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman,
linux-media, devel, Shailendra Verma, Ravikant Sharma
Cc: linux-kernel, vidushi.koul
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@samsung.com>
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: Staging: Media: Lirc - Fix possible ERR_PTR() dereferencing.
2016-09-20 6:51 Staging: Media: Lirc - Fix possible ERR_PTR() dereferencing Shailendra Verma
@ 2016-09-20 8:45 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2016-09-20 8:45 UTC (permalink / raw)
To: Shailendra Verma
Cc: Jarod Wilson, Mauro Carvalho Chehab, Greg Kroah-Hartman,
linux-media, devel, Ravikant Sharma, vidushi.koul, linux-kernel
On Tue, Sep 20, 2016 at 12:21:21PM +0530, Shailendra Verma wrote:
> 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@samsung.com>
> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
Calling kfree(NULL) is fine so there is no bug in the original code.
Also this patch creates a new locking bug.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-20 8:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-20 6:51 Staging: Media: Lirc - Fix possible ERR_PTR() dereferencing Shailendra Verma
2016-09-20 8:45 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).