Skip to contentSkip to conversation

drivers/media/video/videocodec.c: check kmalloc() return value.

PATCH In review Amit Choudhary 3 participants 3 messages Mar 9, 2007 – Mar 12, 2007 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/media/video/videocodec.c: check kmalloc() return value.

Description: Check the return value of kmalloc() in function videocodec_build_table(), in file drivers/media/video/videocodec.c.

drivers/media/video/videocodec.c +2 -0
index 2ae3fb2..16fc1dd 100644
@@ -348,6 +348,8 @@ #define LINESIZE 100
 	kfree(videocodec_buf);
 	videocodec_buf = (char *) kmalloc(size, GFP_KERNEL);
 
+	if (!videocodec_buf)
+		return 0;
 	i = 0;
 	i += scnprintf(videocodec_buf + i, size - 1,
 		      "<S>lave or attached <M>aster name  type flags    magic    ");
#1 lore raw
Quoted 9 lines · Amit Choudhary

Description: Check the return value of kmalloc() in function videocodec_build_table(), in file drivers/media/video/videocodec.c.

drivers/media/video/videocodec.c +0 -0
index 2ae3fb2..16fc1dd 100644

drivers/media/video/videocodec.c #define LINESIZE 100 · line 355

Quoted 8 lines
drivers/media/video/videocodec.c +2 -0
@@ -348,6 +348,8 @@ #define LINESIZE 100
 	kfree(videocodec_buf);
 	videocodec_buf = (char *) kmalloc(size, GFP_KERNEL);
 
+	if (!videocodec_buf)
+		return 0;
 	i = 0;
 	i += scnprintf(videocodec_buf + i, size - 1,
 		      "<S>lave or attached <M>aster name  type flags    magic    ");

Can you also remove useless (char *) cast above ?

Signature · 2 lines
Andrey Panin		| Linux and UNIX system administrator
[email protected]		| PGP key: wwwkeys.pgp.net
#2 lore raw
In reply to Amit Choudhary

Hi Amit,

Quoted 2 lines · Amit Choudhary

Description: Check the return value of kmalloc() in function videocodec_build_table(), in file drivers/media/video/videocodec.c.

No need for `Description:'. This line is automatically put in the logs as a patch description if the patch got accepted.

It's better not to use very large lines.

Also there's no need to specify the exact function in the log, it's already displayed in the patch.

Quoted 3 lines

As said in Documentation/SubmittingPatches put a "---" line after Signed-off-by signature.

Thanks,

Signature · 2 lines
Ahmed S. Darwish
http://darwish.07.googlepages.com