Re: Fault tolerance/bad patch, [was Re: [PATCH 29/30] [PATCH] PCI Hotplug: fake NULL pointer dereferences in IBM Hot Plug Controller Driver]

From: Eric Sesterhenn / Snakebyte
Date: Fri Jun 23 2006 - 11:51:43 EST


* Alan Cox (alan@xxxxxxxxxxxxxxxxxxx) wrote:
> Ar Gwe, 2006-06-23 am 10:04 -0500, ysgrifennodd Linas Vepstas:
> > If someone in the future changes the hotplug core so that it
> > sometimes returns a null value, this code will potentially crash
> > and/or do other bad things (corrupt, invalid state, etc.)
> > This means that this routine will no longer be "robust" in the face of
> > changes in other parts of the kernel.
>
> "Potentially".
>
> But if you replaced it with
>
> BUG_ON(value == NULL);
>
> you'd both clean up the if and improve the reliability even more
>
> > I can hear the objections:
> > -- Performance. B.S. This routine is not performance critical, it will
> > get called once a week, once a month or less often; a few extra
> > cycles are utterly irrelevant.
>
> (and half the time gcc eliminates the test itself)
>

I guess the BUG_ON makes more sense than keeping the
check, the reason coverity stumbled across this,
is the debug("get_attention_status - Exit rc[%d] value[%x]\n", rc,
*value); call some lines later, which uses the pointer.
If we just keep the check, we should also put one
around the debug statement

Greetings, Eric
-
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/