Re: [PATCH v2] scsi: pm8001: Fix data race in sysfs SAS address read

From: Chengfeng Ye

Date: Fri Jan 16 2026 - 08:42:08 EST


Hi James,

> I think everyone would agree this can't happen for built in drivers
> (because user space doesn't start until long after driver init), so
> your theory above rests on a race between inserting the module and a
> tool reading the file which can be fixed by waiting a short period ...
> it just doesn't seem to be an important issue.

True for the case of built-in driver (most use scenario), the race
window is short.

> Whereas taking the internal host lock in a
> sysfs read routine could potentially be a DoS vector.

Agree that using a spinlock just to fix this hardly triggered output
issue may not be a good idea.
I think this theoretical uninitialized/torn-read issue could also be
fixed by delaying the creation of the sysfs folder until
initialization finishes. Can help create a new patch if you'd like to
improve the code, or we can just ignore it if it is not worth
bothering with a small issue like this.

Best regards,
Chengfeng