driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: meson: Add NULL check after the call to kmalloc()
@ 2019-09-04  8:22 Austin Kim
  2019-09-04  8:43 ` Rasmus Villemoes
  2019-09-04  8:45 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Austin Kim @ 2019-09-04  8:22 UTC (permalink / raw)
  To: mchehab, khilman
  Cc: mjourdan, devel, gregkh, linux-kernel, linux-amlogic,
	linux-arm-kernel, linux-media

If the kmalloc() return NULL, the NULL pointer dereference will occur.
	new_ts->ts = ts;

Add exception check after the call to kmalloc() is made.

Signed-off-by: Austin Kim <austindh.kim@gmail.com>
---
 drivers/staging/media/meson/vdec/vdec_helpers.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.c b/drivers/staging/media/meson/vdec/vdec_helpers.c
index f16948b..e7e56d5 100644
--- a/drivers/staging/media/meson/vdec/vdec_helpers.c
+++ b/drivers/staging/media/meson/vdec/vdec_helpers.c
@@ -206,6 +206,10 @@ void amvdec_add_ts_reorder(struct amvdec_session *sess, u64 ts, u32 offset)
 	unsigned long flags;
 
 	new_ts = kmalloc(sizeof(*new_ts), GFP_KERNEL);
+	if (!new_ts) {
+		dev_err(sess->core->dev, "Failed to kmalloc()\n");
+		return;
+	}
 	new_ts->ts = ts;
 	new_ts->offset = offset;
 
-- 
2.6.2

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

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

end of thread, other threads:[~2019-09-04 22:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04  8:22 [PATCH] media: meson: Add NULL check after the call to kmalloc() Austin Kim
2019-09-04  8:43 ` Rasmus Villemoes
2019-09-04 22:47   ` Austin Kim
2019-09-04  8:45 ` Greg KH
2019-09-04 22:39   ` Austin Kim

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