Re: [PATCH] net: srand_mac(): fix -ENODEV crash with CONFIG_DM_RNG

Simon Glass <[email protected]>
Newsgroups gmane.comp.boot-loaders.u-boot.general,gmane.comp.boot-loaders.u-boot
Message-ID <CAFLszTiLQQi4NKt8iNu4rwGOr+7CLT5sEx71=XWJgTHs7SS49g@mail.gmail.com>
+Matthias Brugger <[email protected]>

Hi Graeme,

On 2026-08-06T20:43:42, Graeme Smecher <[email protected]> wrote:
> 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()")

>
> Signed-off-by: Graeme Smecher <[email protected]>
>
> net/net_rand.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/net/net_rand.h b/net/net_rand.h
> @@ -44,7 +44,7 @@ static inline void srand_mac(void)
> -             if (ret) {
> +             if (!ret) {

Reviewed-by: Simon Glass <[email protected]>

Regards,
Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.