Re: [patch 9/9] Add bcm43xx HW RNG support

From: Denis Vlasenko
Date: Fri May 12 2006 - 11:16:38 EST


On Friday 12 May 2006 13:35, Michael Buesch wrote:
> +static int bcm43xx_rng_read(struct hwrng *rng, u32 *data)
> +{
> + struct bcm43xx_private *bcm = (struct bcm43xx_private *)rng->priv;
> + unsigned long flags;
> +
> + bcm43xx_lock(bcm, flags);
> + *data = bcm43xx_read16(bcm, BCM43xx_MMIO_RNG);

You are storing random 16-bit value _and_ 16 zero bits
into 32-bit memory location. Probably not a problem for
little-endian machine (you return 2, indicating that there
are only 2 bytes of randomness), but on big endian?

Didn't you mean

*(u16*)data = bcm43xx_read16(bcm, BCM43xx_MMIO_RNG); ?

> + bcm43xx_unlock(bcm, flags);
> +
> + return (sizeof(u16));
> +}

--
vda
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/