Re: [PATCH 1/2] fs: logfs NULL pointer check added

From: Andrew Morton
Date: Fri Dec 07 2012 - 19:39:44 EST


On Tue, 27 Nov 2012 16:54:58 +0530
Abhijit Pawar <abhi.c.pawar@xxxxxxxxx> wrote:

> This patch fixes Bug 49921 - Missing NULL check of return value of logfs_get_write_page() in function btree_write_block()
>
> Signed-off-by: Abhijit Pawar <abhi.c.pawar@xxxxxxxxx>
> ---
> fs/logfs/readwrite.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c
> index e1a3b6b..53596ce 100644
> --- a/fs/logfs/readwrite.c
> +++ b/fs/logfs/readwrite.c
> @@ -2202,6 +2202,7 @@ void btree_write_block(struct logfs_block *block)
>
> inode = logfs_safe_iget(block->sb, block->ino, &cookie);
> page = logfs_get_write_page(inode, block->bix, block->level);
> + BUG_ON(!page);
>
> err = logfs_readpage_nolock(page);
> BUG_ON(err);

We don't gain anything from this change. If page==NULL then
logfs_readpage_nolock() will oops and will provide the same information
as BUG().


A better fix would be to teach logfs_get_write_page() to return a
proper ERR_PTR errno (not just a gee-i-goofed boolean, guys) then teach
btree_write_block() to process that error appropriately: clean up and
propagate it back.

Right now, a visit from the oom-killer will cause btree_write_block()
to kill the kernel.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/