Re: [PATCH 1/3] random: unify early init crng load accounting

From: Jason A. Donenfeld
Date: Mon Feb 21 2022 - 10:22:54 EST


On Mon, Feb 21, 2022 at 6:50 AM Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
>
> On Sun, Feb 13, 2022 at 12:10:20AM +0100, Jason A. Donenfeld wrote:
> > -static size_t crng_fast_load(const void *cp, size_t len)
> > +static size_t crng_pre_init_inject(const void *cp, size_t len,
> > + bool fast, bool account)
>
> This would be a good chance to rename 'cp' to something more usual, like 'in'.

I'll do that. By the way, if you feel inclined to clean up other
instances of 'cp' and other odd variable names, feel free to send a
patch devoted to that.

>
> Also, there's still a mention of "crng_{fast,slow}_load" in crng_make_state().

Nice catch, will fix.

>
> > + const u8 *src = cp;
> > +
> > + if (fast) {
> > + if (!spin_trylock_irqsave(&base_crng.lock, flags))
> > + return 0;
> > + } else
> > + spin_lock_irqsave(&base_crng.lock, flags);
>
> Nit: the kernel coding style requires braces around the else clause here.

Not the biggest fan of this one, but will do.

Jason