Re: [PATCH v3] ssb: Fix potential NULL pointer dereference in ssb_device_uevent

From: Michael Büsch
Date: Thu Mar 07 2024 - 13:24:53 EST


On Thu, 7 Mar 2024 16:41:42 +0300
Rand Deeb <rand.sec96@xxxxxxxxx> wrote:

> Given that null is improbable in this context due to the calls being made
> through uevent, we should eliminate the redundant condition. In light of
> this, would you recommend sending a new version (v4)

No.

We should _not_ eliminate NULL checks in this code.
Ever.
There is only one reason to eliminate NULL checks:
In extremely performance critical code, if it improves performance
significantly and it is clearly documented that the pointer can never be NULL.

This is not that case here. This is not critical code.

Having NULL checks is defensive programming.
Removing NULL checks is a hazard.
Not having these checks is a big part of why security sucks in today's software.

V3 shall be applied, because it fixes a clear bug. Whether this bug can actually
be triggered or not in today's kernel doesn't matter.

--
Michael Büsch
https://bues.ch/

Attachment: pgp5goLlWhDxX.pgp
Description: OpenPGP digital signature