linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] s5k5baf: Add missing error check for devm_kzalloc
@ 2015-02-05 10:09 Kiran Padwal
  2015-02-05 11:10 ` Andrzej Hajda
  0 siblings, 1 reply; 2+ messages in thread
From: Kiran Padwal @ 2015-02-05 10:09 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Andrzej Hajda, Kyungmin Park, linux-media, linux-kernel,
	kiran.padwal21, Kiran Padwal

This patch add a missing a check on the return value of devm_kzalloc,
which would cause a NULL pointer dereference in a OOM situation.

Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
---
 drivers/media/i2c/s5k5baf.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 60a74d8..156b975 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -374,6 +374,8 @@ static int s5k5baf_fw_parse(struct device *dev, struct s5k5baf_fw **fw,
 	count -= S5K5BAG_FW_TAG_LEN;
 
 	d = devm_kzalloc(dev, count * sizeof(u16), GFP_KERNEL);
+	if (!d)
+		return -ENOMEM;
 
 	for (i = 0; i < count; ++i)
 		d[i] = le16_to_cpu(data[i]);
-- 
1.7.9.5


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

end of thread, other threads:[~2015-02-05 11:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-05 10:09 [PATCH] [media] s5k5baf: Add missing error check for devm_kzalloc Kiran Padwal
2015-02-05 11:10 ` Andrzej Hajda

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