patch-1.3.25 linux/drivers/block/sonycd535.c

Next file: linux/drivers/char/README.scc
Previous file: linux/arch/i386/kernel/ptrace.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.24/linux/drivers/block/sonycd535.c linux/drivers/block/sonycd535.c
@@ -1659,12 +1659,32 @@
 #else /* MODULE */
 				sony_toc = (struct s535_sony_toc *)
 					kmalloc(sizeof *sony_toc, GFP_KERNEL);
+				if (sony_toc == NULL)
+					return -ENOMEM;
 				last_sony_subcode = (struct s535_sony_subcode *)
 					kmalloc(sizeof *last_sony_subcode, GFP_KERNEL);
+				if (last_sony_subcode == NULL) {
+					kfree(sony_toc);
+					return -ENOMEM;
+				}
 				sony_buffer = (Byte **)
 					kmalloc(4 * sony_buffer_sectors, GFP_KERNEL);
-				for (i = 0; i < sony_buffer_sectors; i++)
+				if (sony_buffer == NULL) {
+					kfree(sony_toc);
+					kfree(last_sony_subcode);
+					return -ENOMEM;
+				}
+				for (i = 0; i < sony_buffer_sectors; i++) {
 					sony_buffer[i] = (Byte *)kmalloc(2048, GFP_KERNEL);
+					if (sony_buffer[i] == NULL) {
+						while (--i>=0)
+							kfree(sony_buffer[i]);
+						kfree(sony_buffer);
+						kfree(sony_toc);
+						kfree(last_sony_subcode);
+						return -ENOMEM;
+					}
+				}
 #endif /* MODULE */
 				initialized = 1;
 			}

FUNET's LINUX-ADM group, [email protected]
TCL-scripts by Sam Shen, [email protected] with Sam's (original) version
of this