Re: [PATCH] ocfs2: dereference before NULL check in ocfs2_direct_IO_get_blocks()

From: Joel Becker
Date: Sat Jun 03 2006 - 17:16:09 EST


On Sat, Jun 03, 2006 at 11:15:58PM +0400, Alexey Dobriyan wrote:
> On Sat, Jun 03, 2006 at 11:34:39AM -0400, Florin Malita wrote:
> > 'bh_result' & 'inode' are explicitly checked against NULL so they
> > shouldn't be dereferenced prior to that.
> >
> > Coverity ID: 1273, 1274.
>
> AFAICS, the patch is BS, as usual with this type of patches.
>
> Can "inode" and "bh_result" be NULL here? I bet they can't.

This is a common result of this sort of scan. The scan merely
provides good information, not a perfect patch. There are two
possibilities:

1) The scan is right, and the dereference is dangerous. The
patch is correct.
2) The dereference is not dangerous ("can't happen"), and the
later check for NULL is spurious. A correct patch would
merely remove the check.

This is clearly a case of (2), but I bet that (1) is seen just
as often.

Joel

--

Life's Little Instruction Book #444

"Never underestimate the power of a kind word or deed."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@xxxxxxxxxx
Phone: (650) 506-8127
-
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/