Re: [PATCH 11/14] Big kfree NULL check cleanup - arch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/14/05, Matthew Wilcox <[email protected]> wrote:
> On Thu, Oct 13, 2005 at 09:29:39PM +0200, Jesper Juhl wrote:
> > This is the arch/ part of the big kfree cleanup patch.
>
> Ignore the parisc part; it conflicts with simply deleting that code
> (patch from hch).
>
Attached is a patch to revert that.


--
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
--- linux-2.6.14-rc4/arch/parisc/kernel/ioctl32.c.a	2005-10-14 14:24:10.000000000 +0200
+++ linux-2.6.14-rc4/arch/parisc/kernel/ioctl32.c	2005-10-14 14:24:19.000000000 +0200
@@ -104,9 +104,12 @@ static int drm32_version(unsigned int fd
 	}
 
 out:
-	kfree(kversion.name);
-	kfree(kversion.date);
-	kfree(kversion.desc);
+	if (kversion.name)
+		kfree(kversion.name);
+	if (kversion.date)
+		kfree(kversion.date);
+	if (kversion.desc)
+		kfree(kversion.desc);
 	return ret;
 }
 
@@ -163,7 +166,9 @@ static int drm32_getsetunique(unsigned i
 			ret = -EFAULT;
 	}
 
-	kfree(karg.unique);
+	if (karg.unique != NULL)
+		kfree(karg.unique);
+
 	return ret;
 }
 
@@ -260,6 +265,7 @@ static int drm32_info_bufs(unsigned int 
 	}
 
 	kfree(karg.list);
+
 	return ret;
 }
 
@@ -299,6 +305,7 @@ static int drm32_free_bufs(unsigned int 
 
 out:
 	kfree(karg.list);
+
 	return ret;
 }
 
@@ -487,10 +494,15 @@ static int drm32_dma(unsigned int fd, un
 	}
 
 out:
-	kfree(karg.send_indices);
-	kfree(karg.send_sizes);
-	kfree(karg.request_indices);
-	kfree(karg.request_sizes);
+	if (karg.send_indices)
+		kfree(karg.send_indices);
+	if (karg.send_sizes)
+		kfree(karg.send_sizes);
+	if (karg.request_indices)
+		kfree(karg.request_indices);
+	if (karg.request_sizes)
+		kfree(karg.request_sizes);
+
 	return ret;
 }
 
@@ -543,7 +555,9 @@ static int drm32_res_ctx(unsigned int fd
 			ret = -EFAULT;
 	}
 
-	kfree(karg.contexts);
+	if (karg.contexts)
+		kfree(karg.contexts);
+
 	return ret;
 }
 

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux