linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cx231xx: correctly handling failed allocation
@ 2015-12-29 18:53 Insu Yun
  2015-12-29 19:05 ` Devin Heitmueller
  0 siblings, 1 reply; 2+ messages in thread
From: Insu Yun @ 2015-12-29 18:53 UTC (permalink / raw)
  To: mchehab, hans.verkuil, prabhakar.csengg, scott.jiang.linux,
	linux-media, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun

Since kmalloc can be failed in memory pressure, 
if not properly handled, NULL dereference can be happend

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/media/usb/cx231xx/cx231xx-417.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index 47a98a2..9725e4f 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1382,6 +1382,8 @@ static int cx231xx_bulk_copy(struct cx231xx *dev, struct urb *urb)
 	buffer_size = urb->actual_length;
 
 	buffer = kmalloc(buffer_size, GFP_ATOMIC);
+	if (!buffer)
+		return -ENOMEM;
 
 	memcpy(buffer, dma_q->ps_head, 3);
 	memcpy(buffer+3, p_buffer, buffer_size-3);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cx231xx: correctly handling failed allocation
  2015-12-29 18:53 [PATCH] cx231xx: correctly handling failed allocation Insu Yun
@ 2015-12-29 19:05 ` Devin Heitmueller
  0 siblings, 0 replies; 2+ messages in thread
From: Devin Heitmueller @ 2015-12-29 19:05 UTC (permalink / raw)
  To: Insu Yun
  Cc: Mauro Carvalho Chehab, Hans Verkuil, Prabhakar Lad,
	scott.jiang.linux, Linux Media Mailing List, Linux Kernel,
	taesoo, yeongjin.jang, insu, changwoo

On Tue, Dec 29, 2015 at 1:53 PM, Insu Yun <wuninsu@gmail.com> wrote:
> Since kmalloc can be failed in memory pressure,
> if not properly handled, NULL dereference can be happend
>
> Signed-off-by: Insu Yun <wuninsu@gmail.com>
> ---
>  drivers/media/usb/cx231xx/cx231xx-417.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
> index 47a98a2..9725e4f 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-417.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-417.c
> @@ -1382,6 +1382,8 @@ static int cx231xx_bulk_copy(struct cx231xx *dev, struct urb *urb)
>         buffer_size = urb->actual_length;
>
>         buffer = kmalloc(buffer_size, GFP_ATOMIC);
> +       if (!buffer)
> +               return -ENOMEM;

A kmalloc() call inside a bulk handler running in softirq context?
That doesn't look right.

That said, I don't have any specific objection to the patch (which I'm
assuming came from some automated tool), but I suspect the cx231xx-417
code is probably completely broken.  The only device I've ever seen
that has the cx23102 and cx23417 is one of the Polaris EVKs, which
AFAIK nobody has ever shipped a production design based on.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-29 19:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-29 18:53 [PATCH] cx231xx: correctly handling failed allocation Insu Yun
2015-12-29 19:05 ` Devin Heitmueller

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).