All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: meson: vdec: Fix a NULL pointer dereference in amvdec_add_ts()
@ 2021-11-30 16:12 ` Zhou Qingyang
  0 siblings, 0 replies; 29+ messages in thread
From: Zhou Qingyang @ 2021-11-30 16:12 UTC (permalink / raw)
  To: zhou1615
  Cc: kjlu, Neil Armstrong, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Hans Verkuil,
	Maxime Jourdan, linux-media, linux-amlogic, linux-staging,
	linux-arm-kernel, linux-kernel

In amvdec_add_ts(), there is a dereference of kzalloc(), which could lead
to a NULL pointer dereference on failure of kzalloc().

I fix this bug by adding a NULL check of new_ts.

This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.

Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.

Builds with CONFIG_VIDEO_MESON_VDEC=m show no new warnings,
and our static analyzer no longer warns about this code.

Fixes: 876f123b8956 ("media: meson: vdec: bring up to compliance")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
---
 drivers/staging/media/meson/vdec/vdec_helpers.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.c b/drivers/staging/media/meson/vdec/vdec_helpers.c
index b9125c295d1d..41297c2f8f9a 100644
--- a/drivers/staging/media/meson/vdec/vdec_helpers.c
+++ b/drivers/staging/media/meson/vdec/vdec_helpers.c
@@ -234,6 +234,11 @@ void amvdec_add_ts(struct amvdec_session *sess, u64 ts,
 	unsigned long flags;
 
 	new_ts = kzalloc(sizeof(*new_ts), GFP_KERNEL);
+	if (!new_ts) {
+		dev_err(sess->core->dev_dec,
+			"No enough memory in %s\n", __func__);
+		return;
+	}
 	new_ts->ts = ts;
 	new_ts->tc = tc;
 	new_ts->offset = offset;
-- 
2.25.1


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

end of thread, other threads:[~2022-01-12  9:04 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 16:12 [PATCH] media: meson: vdec: Fix a NULL pointer dereference in amvdec_add_ts() Zhou Qingyang
2021-11-30 16:12 ` Zhou Qingyang
2021-11-30 16:12 ` Zhou Qingyang
2021-12-01  8:41 ` Dan Carpenter
2021-12-01  8:41   ` Dan Carpenter
2021-12-01  8:41   ` Dan Carpenter
2021-12-02 16:03   ` [PATCH v2] " Zhou Qingyang
2021-12-02 16:03     ` Zhou Qingyang
2021-12-02 16:03     ` Zhou Qingyang
2021-12-03 13:30     ` Dan Carpenter
2021-12-03 13:30       ` Dan Carpenter
2021-12-03 13:30       ` Dan Carpenter
2021-12-14 13:46     ` Mauro Carvalho Chehab
2021-12-14 13:46       ` Mauro Carvalho Chehab
2021-12-14 13:46       ` Mauro Carvalho Chehab
2021-12-14 14:16       ` Greg Kroah-Hartman
2021-12-14 14:16         ` Greg Kroah-Hartman
2021-12-14 14:16         ` Greg Kroah-Hartman
2021-12-15  3:35       ` [PATCH v3] " Zhou Qingyang
2021-12-15  3:35         ` Zhou Qingyang
2021-12-15  3:35         ` Zhou Qingyang
2022-01-11  9:16         ` Hans Verkuil
2022-01-11  9:16           ` Hans Verkuil
2022-01-11  9:16           ` Hans Verkuil
     [not found]           ` <CA+Cm_xSOv5NnW5GXcKKGi8bQSvT45iH6=65YJk3EG6uW0c5_Vw@mail.gmail.com>
2022-01-11 14:16             ` Hans Verkuil
2022-01-12  8:57             ` Neil Armstrong
2022-01-12  8:57               ` Neil Armstrong
2022-01-12  8:57               ` Neil Armstrong
2022-01-12  9:04               ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.