Patchwork hwrng: exynos - Signedness bug in exynos_trng_do_read()

login
register
mail settings
Submitter Dan Carpenter
Date Jan. 10, 2018, 9:36 a.m.
Message ID <20180110093658.kxnmhqkoow7o2xab@mwanda>
Download mbox | patch
Permalink /patch/10154645/
State Accepted
Delegated to: Herbert Xu
Headers show

Comments

Dan Carpenter - Jan. 10, 2018, 9:36 a.m.
"val" needs to be signed for the error handling to work.

Fixes: 6cd225cc5d8a ("hwrng: exynos - add Samsung Exynos True RNG driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Krzysztof Kozlowski - Jan. 10, 2018, 10:06 a.m.
On Wed, Jan 10, 2018 at 10:36 AM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:
> "val" needs to be signed for the error handling to work.
>
> Fixes: 6cd225cc5d8a ("hwrng: exynos - add Samsung Exynos True RNG driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
> index 34d6f51ecbee..f4643e3ec346 100644
> --- a/drivers/char/hw_random/exynos-trng.c
> +++ b/drivers/char/hw_random/exynos-trng.c
> @@ -55,7 +55,7 @@ static int exynos_trng_do_read(struct hwrng *rng, void *data, size_t max,
>                                bool wait)
>  {
>         struct exynos_trng_dev *trng;
> -       u32 val;
> +       int val;

It seems that one forgot to run Smatch on the driver :).

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>

Best regards,
Krzysztof
Łukasz Stelmach - Jan. 11, 2018, 12:38 p.m.
It was <2018-01-10 śro 10:36>, when Dan Carpenter wrote:
> "val" needs to be signed for the error handling to work.
>
> Fixes: 6cd225cc5d8a ("hwrng: exynos - add Samsung Exynos True RNG driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>

Acked-by: Łukasz Stelmach <l.stelmach@samsung.com>
Herbert Xu - Jan. 18, 2018, 12:02 p.m.
On Wed, Jan 10, 2018 at 12:36:58PM +0300, Dan Carpenter wrote:
> "val" needs to be signed for the error handling to work.
> 
> Fixes: 6cd225cc5d8a ("hwrng: exynos - add Samsung Exynos True RNG driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Patch applied.  Thanks.

Patch

diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 34d6f51ecbee..f4643e3ec346 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -55,7 +55,7 @@  static int exynos_trng_do_read(struct hwrng *rng, void *data, size_t max,
 			       bool wait)
 {
 	struct exynos_trng_dev *trng;
-	u32 val;
+	int val;
 
 	max = min_t(size_t, max, (EXYNOS_TRNG_FIFO_LEN * 4));