lkml.org 
[lkml]   [2005]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 09/14] Big kfree NULL check cleanup - misc remaining drivers
On 10/13/05, Miller, Mike (OS Dev) <Mike.Miller@hp.com> wrote:
> > From: Jesper Juhl [mailto:jesper.juhl@gmail.com]
> > This is the remaining misc drivers/ part of the big kfree
> > cleanup patch.
> >
> > Remove pointless checks for NULL prior to calling kfree() in
> > misc files in drivers/.
> >
> >
> > --- linux-2.6.14-rc4-orig/drivers/block/cciss.c
> > 2005-10-11 22:41:05.000000000 +0200
> > +++ linux-2.6.14-rc4/drivers/block/cciss.c 2005-10-12
> > 17:43:18.000000000 +0200
> > @@ -1096,14 +1096,11 @@ static int cciss_ioctl(struct inode *ino
> > cleanup1:
> > if (buff) {
> > for(i=0; i<sg_used; i++)
> > - if(buff[i] != NULL)
> > - kfree(buff[i]);
>
> I'm not sure I agree that these are pointless checks. They're not in the
> main code path so nothing is lost by checking first. What if the pointer
> is NULL????
>

If the pointer is NULL then this bit of code in kfree takes care of things :

void kfree(const void *objp)
{
...

if (unlikely(!objp))
return;
...

Runtime behaviour is exactely the same.
kfree checks if the pointer passed to it is NULL in any case and just
returns if it is.


--
Jesper Juhl <jesper.juhl@gmail.com>
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-10-13 22:12    [W:0.040 / U:1.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site