patch-1.3.25 linux/fs/binfmt_elf.c

Next file: linux/fs/exec.c
Previous file: linux/drivers/pci/pci.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.24/linux/fs/binfmt_elf.c linux/fs/binfmt_elf.c
@@ -389,6 +389,10 @@
 	
 	elf_phdata = (struct elf_phdr *) kmalloc(elf_ex.e_phentsize * 
 						 elf_ex.e_phnum, GFP_KERNEL);
+	if (elf_phdata == NULL) {
+		MOD_DEC_USE_COUNT;
+		return -ENOMEM;
+	}
 	
 	retval = read_exec(bprm->inode, elf_ex.e_phoff, (char *) elf_phdata,
 			   elf_ex.e_phentsize * elf_ex.e_phnum, 1);
@@ -426,6 +430,11 @@
 			
 			elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz, 
 							   GFP_KERNEL);
+			if (elf_interpreter == NULL) {
+				kfree (elf_phdata);
+				MOD_DEC_USE_COUNT;
+				return -ENOMEM;
+			}
 			
 			retval = read_exec(bprm->inode,elf_ppnt->p_offset,elf_interpreter,
 					   elf_ppnt->p_filesz, 1);
@@ -738,6 +747,10 @@
 	
 	elf_phdata =  (struct elf_phdr *) 
 		kmalloc(sizeof(struct elf_phdr) * elf_ex.e_phnum, GFP_KERNEL);
+	if (elf_phdata == NULL) {
+		MOD_DEC_USE_COUNT;
+		return -ENOMEM;
+	}
 	
 	retval = read_exec(inode, elf_ex.e_phoff, (char *) elf_phdata,
 			   sizeof(struct elf_phdr) * elf_ex.e_phnum, 1);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this