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

From: Alan Cox
Date: Fri Jun 23 2006 - 11:11:34 EST


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)


-
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/