net: srand_mac(): fix -ENODEV crash with CONFIG_DM_RNG
A message that is not in the archive (sent off-list or not yet received): [email protected]
Simon Glass
Reviewed-by+Matthias Brugger <[email protected]>
Hi Graeme,
Quoted 4 lines · Graeme Smecher
net:
srand_mac(): fix-ENODEVcrash withCONFIG_DM_RNGThe
uclass_get_device()return-value check was inverted, resulting in a synchronous abort when-ENODEVwas 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:
net/net_rand.h static inline void srand_mac(void) · line 44
Quoted 10 lines
Signed-off-by Graeme Smecher <[email protected]>
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
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 whenuclass_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