This patch (attached) removes pointless checks for NULL before kfree()'ing 
a pointer. kfree() handles NULL pointers just fine, so checking the 
pointer first is redundant.

Signed-off-by: Jesper Juhl <[EMAIL PROTECTED]>


-- 
Jesper Juhl

diff -up linux-2.6.11-mm3/fs/cifs/file.c.with_patch_2 
linux-2.6.11-mm3/fs/cifs/file.c
--- linux-2.6.11-mm3/fs/cifs/file.c.with_patch_2        2005-03-15 
22:49:33.000000000 +0100
+++ linux-2.6.11-mm3/fs/cifs/file.c     2005-03-15 22:51:01.000000000 +0100
@@ -148,8 +148,7 @@ int cifs_open(struct inode *inode, struc
        able to simply do a filemap_fdatawrite/filemap_fdatawait first */
        buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
        if (buf == NULL) {
-               if (full_path)
-                       kfree(full_path);
+               kfree(full_path);
                FreeXid(xid);
                return -ENOMEM;
        }
@@ -248,10 +247,8 @@ int cifs_open(struct inode *inode, struc
                }
        }
 
-       if (buf)
-               kfree(buf);
-       if (full_path)
-               kfree(full_path);
+       kfree(buf);
+       kfree(full_path);
        FreeXid(xid);
        return rc;
 }
@@ -342,8 +339,7 @@ static int cifs_reopen_file(struct inode
 /*     buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
        if (buf == 0) {
                up(&pCifsFile->fh_sem);
-               if (full_path)
-                       kfree(full_path);
+               kfree(full_path);
                FreeXid(xid);
                return -ENOMEM;
        } */
@@ -396,8 +392,7 @@ static int cifs_reopen_file(struct inode
                }
        }
 
-       if (full_path)
-               kfree(full_path);
+       kfree(full_path);
        FreeXid(xid);
        return rc;
 }
@@ -431,8 +426,7 @@ int cifs_close(struct inode *inode, stru
                list_del(&pSMBFile->flist);
                list_del(&pSMBFile->tlist);
                write_unlock(&file->f_owner.lock);
-               if (pSMBFile->search_resume_name)
-                       kfree(pSMBFile->search_resume_name);
+               kfree(pSMBFile->search_resume_name);
                kfree(file->private_data);
                file->private_data = NULL;
        } else

Reply via email to