Re: [PATCH] if (foo) kfree(foo) /fs cleanup + reverted JBD code

Raja R Harinath (harinath@cs.umn.edu)
Sat, 01 Dec 2001 14:40:58 -0600


Zwane Mwaikambo <zwane@linux.realnet.co.sz> writes:

> diff -urN linux-2.5.1-pre4.orig/fs/coda/inode.c linux-2.5.1-pre4.kfree/fs/coda/inode.c
> --- linux-2.5.1-pre4.orig/fs/coda/inode.c Fri Apr 27 23:09:37 2001
> +++ linux-2.5.1-pre4.kfree/fs/coda/inode.c Fri Nov 30 23:45:08 2001
> @@ -164,11 +164,10 @@
>
> error:
> EXIT;
> - if (sbi) {
> - kfree(sbi);
> - if(vc)
> - vc->vc_sb = NULL;
> - }
> + kfree(sbi);
> + if (vc)
> + vc->vc_sb = NULL;
> +
> if (root)
> iput(root);

Not a safe change. If you really really really want to change it, it
should be

if (sbi && vc)
vc->vc_sb = NULL;
kfree(sbi);

Then, the maintainer of the code can decide if that's what he meant.

> - if (opts.iocharset) {
> - printk("FAT: freeing iocharset=%s\n", opts.iocharset);
> - kfree(opts.iocharset);
> - }
> - if(sbi->private_data)
> - kfree(sbi->private_data);
> + printk("FAT: freeing iocharset=%s\n", opts.iocharset);
> + kfree(opts.iocharset);

And, you get a Oops in 'printk' in the bargain. The following is
better, but doesn't really buy you much.

if (opts.iocharset)
printk("FAT: freeing iocharset=%s\n", opts.iocharset);
kfree(opts.iocharset);

> printk("jffs_find_child(): Didn't find the file \"%s\".\n",
> (copy ? copy : ""));
> - if (copy) {
> - kfree(copy);
> + kfree(copy);
> }
^
Missed the closing brace.

- Hari

-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash
-
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/