[PATCH] vfree() cleanup in drivers/net/bsd_comp.c

From: Jesper Juhl (juhl-lkml_at_dif.dk)
Date: 06/30/05

  • Next message: Rusty Lynch: "Re: [Ipw2100-devel] Re: ipw2200 can't compile under linux 2.6.13-rc1"
    Date:	Thu, 30 Jun 2005 00:43:36 +0200 (CEST)
    To: Andrew Morton <akpm@osdl.org>
    
    

    You can pass NULL pointers to vfree() just fine. There's no bennefit in
    checking first if the pointer is != NULL.

    Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

    ---
     drivers/net/bsd_comp.c |   20 +++++++-------------
     1 files changed, 7 insertions(+), 13 deletions(-)
    --- linux-2.6.13-rc1-orig/drivers/net/bsd_comp.c	2005-06-17 21:48:29.000000000 +0200
    +++ linux-2.6.13-rc1/drivers/net/bsd_comp.c	2005-06-30 00:38:32.000000000 +0200
    @@ -46,13 +46,13 @@
     
     /*
      * This version is for use with contiguous buffers on Linux-derived systems.
      *
    - *  ==FILEVERSION 20000226==
    + *  ==FILEVERSION 20050630==
      *
      *  NOTE TO MAINTAINERS:
      *     If you modify this file at all, please set the number above to the
    - *     date of the modification as YYMMDD (year month day).
    + *     date of the modification as YYYYMMDD (year month day).
      *     bsd_comp.c is shipped with a PPP distribution as well as with
      *     the kernel; if everyone increases the FILEVERSION number above,
      *     then scripts can do the right thing when deciding whether to
      *     install a new bsd_comp.c file. Don't change the format of that
    @@ -330,25 +330,19 @@ static void bsd_free (void *state)
           {
     /*
      * Release the dictionary
      */
    -	if (db->dict)
    -	  {
    -	    vfree (db->dict);
    -	    db->dict = NULL;
    -	  }
    +	vfree(db->dict);
    +	db->dict = NULL;
     /*
      * Release the string buffer
      */
    -	if (db->lens)
    -	  {
    -	    vfree (db->lens);
    -	    db->lens = NULL;
    -	  }
    +	vfree(db->lens);
    +	db->lens = NULL;
     /*
      * Finally release the structure itself.
      */
    -	kfree (db);
    +	kfree(db);
           }
       }
     
     /*
    -
    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/
    

  • Next message: Rusty Lynch: "Re: [Ipw2100-devel] Re: ipw2200 can't compile under linux 2.6.13-rc1"

    Relevant Pages

    • Re: [PATCH] kfree_skb() bug in 2.4.22
      ... > and vfreeand they have a sanity check for NULL before processing, ... > well as those are also the well-known semantics for the userspace free ... Passing NULL pointers around usually indicates poorly designed ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Hugepages demand paging V1 [2/4]: set_huge_pte() arch updates
      ... >> corruption follows. ... > The other archs are likely much more involved than this. ... > pointers to pointers in such a critical function. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [uml-devel] Re: Uml showstopper bugs for 2.6.14
      ... make sure to at least force frame pointers. ... > sigreturn by hand because it has no access to the libc restorer, ... > needing to restore the stack pointer to where it was on entry. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Pure 64 bootloaders
      ... require everything to use 64-bit pointers. ... There is no way to make Linux robust with unreliable memory ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: slab corruption in test9 (NFS related?)
      ... > consequences are rare? ... pointers to it, I'd expect people to now have a pointer to a _totally_ ... for the new dentry in particular (it might be different if it was the old ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)