On Tue, 2016-08-02 at 01:17 -0400, Martin K. Petersen wrote:
> > > > > > "Johannes" == Johannes Thumshirn <jthumsh...@suse.de>
> > > > > > writes:
> 
> Johannes> Check for the existence of piocb->vport before accessing
> it.
> 
> Applied to 4.8/scsi-queue.

OK, now that this has caused problems, could learn the lessons from it?

Lines like this:

+       BUG_ON(!piocb || !piocb->vport);

Should never appear in code.  They only have the potential to cause
problems if the condition is inexact and they provide precisely no
information over what a NULL deref in the kernel is going to tell us
anyway ... this one even obscures information because you don't know if
pciob was null or pciob->vport when it triggers.

The rule is never BUG_ON a NULL pointer unless you have an extremely
good reason why the kernel NULL deref handler isn't adequate (which
should be documented in the commit log).

James

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to