diff mbox series

[v2,2/3] driver: rng: Fix SMCCC TRNG crash

Message ID 20240131111217.30124-3-o451686892@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series Random Number Generator fixes | expand

Commit Message

Weizhao Ouyang Jan. 31, 2024, 11:12 a.m. UTC
Fix a SMCCC TRNG null pointer crash due to a failed smccc feature
binding.

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
---
 drivers/rng/smccc_trng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dan Carpenter Jan. 31, 2024, 11:48 a.m. UTC | #1
Etienne should have been on the CC list.  He's in
./scripts/get_maintainer.pl so I'm not sure what went wrong there...
I've added him.

On Wed, Jan 31, 2024 at 11:12:16AM +0000, Weizhao Ouyang wrote:
> Fix a SMCCC TRNG null pointer crash due to a failed smccc feature
> binding.
> 
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
> ---
>  drivers/rng/smccc_trng.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/rng/smccc_trng.c b/drivers/rng/smccc_trng.c
> index 3a4bb33941..3087cb991a 100644
> --- a/drivers/rng/smccc_trng.c
> +++ b/drivers/rng/smccc_trng.c
> @@ -166,7 +166,7 @@ static int smccc_trng_probe(struct udevice *dev)
>  	struct smccc_trng_priv *priv = dev_get_priv(dev);
>  	struct arm_smccc_res res;
>  
> -	if (!(smccc_trng_is_supported(smccc->invoke_fn)))
> +	if (!smccc || !(smccc_trng_is_supported(smccc->invoke_fn)))

To me it seems a bit strange that dm_priv_to_rw() can return NULL...
Anyway, probably the Fixes tag should point to when the driver was
added.

Fixes: 53355bb86c25 ("drivers: rng: add smccc trng driver")

regards,
dan carpenter
Dan Carpenter Jan. 31, 2024, 12:31 p.m. UTC | #2
On Wed, Jan 31, 2024 at 02:48:58PM +0300, Dan Carpenter wrote:
> Etienne should have been on the CC list.  He's in
> ./scripts/get_maintainer.pl so I'm not sure what went wrong there...
> I've added him.
> 

Hm...  Etienne's @linaro.org address bounces.  Apparently MAINTAINERS
needs to be updated.

regards,
dan carpenter


> On Wed, Jan 31, 2024 at 11:12:16AM +0000, Weizhao Ouyang wrote:
> > Fix a SMCCC TRNG null pointer crash due to a failed smccc feature
> > binding.
> > 
> > Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
> > ---
> >  drivers/rng/smccc_trng.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/rng/smccc_trng.c b/drivers/rng/smccc_trng.c
> > index 3a4bb33941..3087cb991a 100644
> > --- a/drivers/rng/smccc_trng.c
> > +++ b/drivers/rng/smccc_trng.c
> > @@ -166,7 +166,7 @@ static int smccc_trng_probe(struct udevice *dev)
> >  	struct smccc_trng_priv *priv = dev_get_priv(dev);
> >  	struct arm_smccc_res res;
> >  
> > -	if (!(smccc_trng_is_supported(smccc->invoke_fn)))
> > +	if (!smccc || !(smccc_trng_is_supported(smccc->invoke_fn)))
> 
> To me it seems a bit strange that dm_priv_to_rw() can return NULL...
> Anyway, probably the Fixes tag should point to when the driver was
> added.
> 
> Fixes: 53355bb86c25 ("drivers: rng: add smccc trng driver")
> 
> regards,
> dan carpenter
Ilias Apalodimas Jan. 31, 2024, 12:53 p.m. UTC | #3
+cc Etienne

On Wed, 31 Jan 2024 at 13:49, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> Etienne should have been on the CC list.  He's in
> ./scripts/get_maintainer.pl so I'm not sure what went wrong there...
> I've added him.
>
> On Wed, Jan 31, 2024 at 11:12:16AM +0000, Weizhao Ouyang wrote:
> > Fix a SMCCC TRNG null pointer crash due to a failed smccc feature
> > binding.
> >
> > Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
> > ---
> >  drivers/rng/smccc_trng.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/rng/smccc_trng.c b/drivers/rng/smccc_trng.c
> > index 3a4bb33941..3087cb991a 100644
> > --- a/drivers/rng/smccc_trng.c
> > +++ b/drivers/rng/smccc_trng.c
> > @@ -166,7 +166,7 @@ static int smccc_trng_probe(struct udevice *dev)
> >       struct smccc_trng_priv *priv = dev_get_priv(dev);
> >       struct arm_smccc_res res;
> >
> > -     if (!(smccc_trng_is_supported(smccc->invoke_fn)))
> > +     if (!smccc || !(smccc_trng_is_supported(smccc->invoke_fn)))
>
> To me it seems a bit strange that dm_priv_to_rw() can return NULL...
> Anyway, probably the Fixes tag should point to when the driver was
> added.
>
> Fixes: 53355bb86c25 ("drivers: rng: add smccc trng driver")
>
> regards,
> dan carpenter
>
diff mbox series

Patch

diff --git a/drivers/rng/smccc_trng.c b/drivers/rng/smccc_trng.c
index 3a4bb33941..3087cb991a 100644
--- a/drivers/rng/smccc_trng.c
+++ b/drivers/rng/smccc_trng.c
@@ -166,7 +166,7 @@  static int smccc_trng_probe(struct udevice *dev)
 	struct smccc_trng_priv *priv = dev_get_priv(dev);
 	struct arm_smccc_res res;
 
-	if (!(smccc_trng_is_supported(smccc->invoke_fn)))
+	if (!smccc || !(smccc_trng_is_supported(smccc->invoke_fn)))
 		return -ENODEV;
 
 	/* At least one of 64bit and 32bit interfaces is available */