Skip to contentSkip to conversation

net: srand_mac(): fix -ENODEV crash with CONFIG_DM_RNG

PATCH Simon Glass 2 participants 2 messages Aug 9 – Aug 17 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Simon Glass

author Reviewed-by
#1 lore raw

+Matthias Brugger <[email protected]>

Hi Graeme,

Quoted 4 lines · Graeme Smecher

net: srand_mac(): fix -ENODEV crash with CONFIG_DM_RNG

The uclass_get_device() return-value check was inverted, resulting in a synchronous abort when -ENODEV was returned.

Good catch. This also means the RNG path has never worked: with the inverted check, dm_rng_read() was only called when uclass_get_device() failed, using an uninitialised devp, hence the abort. Boards with a working RNG silently fell back to the MAC seed. You could mention that in the commit message. I believe it is:

Fixes ea707dc0aaaf ("net: Use NDRNG device in srand_mac()")

net/net_rand.h static inline void srand_mac(void) · line 44

Quoted 10 lines

net/net_rand.h | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
net/net_rand.h +1 -1
@@ -44,7 +44,7 @@ static inline void srand_mac(void)
-             if (ret) {
+             if (!ret) {

Regards,
Simon

#2 lore raw

Hi all,

Quoted 3 lines · Simon Glass

Good catch. This also means the RNG path has never worked: with the inverted check, dm_rng_read() was only called when uclass_get_device() failed, using an uninitialised devp, hence the abort. Boards with a working RNG silently fell back to the MAC seed. You could mention that in the commit message. I believe it is:

Fixes ea707dc0aaaf ("net: Use NDRNG device in srand_mac()")

Apologies for the delay while I was traveling. I see it's moot now (my initial patch was picked up) - but you're correct, and an amended message would have been better.

Thanks for the review.

cheers,
Graeme