Re: [PATCH] hwrng: core - reject unknown RNG names

From: Andy Shevchenko

Date: Fri Sep 25 2026 - 06:07:59 EST


On Fri, Sep 25, 2026 at 01:00:39PM +0300, Andy Shevchenko wrote:
> On Thu, Sep 24, 2026 at 11:21:13PM +0200, Thorsten Blum wrote:
> > In rng_current_store(), err is 0 after successfully locking rng_mutex,
> > and if the requested RNG name cannot be found, the function reports
> > success even though the current RNG was not changed.
> >
> > Set err = -ENODEV before searching the RNG list to reject unknown names.
>
> Yeah, from the
>
> > Fixes: 142a27f0a731 ("hwrng: core - Reset user selected rng by writing "" to rng_current")
>
> it looks like it was the intention, but the mutex_lock_interruptible() rewrites
> an error code. That's a good example on why I often tell people to decouple
> assignment from the definition and the very same issue might happen and would be
> hard to debug later on. Surprisingly this happened in the same patch...
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>

Also

Fixes: cb028f1662a9 ("hwrng: core - remove redundant initialization of variable err")

as that one removed the indeed redundant assignment, but forget to fix the issue.

--
With Best Regards,
Andy Shevchenko