lib/crypto/mpi/mpi-mul.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The "err" variable may be returned without an initialized value.
Fixes: 8e3a67f2de87 ("crypto: lib/mpi - Add error checks to extension")
Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
lib/crypto/mpi/mpi-mul.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/crypto/mpi/mpi-mul.c b/lib/crypto/mpi/mpi-mul.c
index 892a246216b9..7e6ff1ce3e9b 100644
--- a/lib/crypto/mpi/mpi-mul.c
+++ b/lib/crypto/mpi/mpi-mul.c
@@ -21,7 +21,7 @@ int mpi_mul(MPI w, MPI u, MPI v)
int usign, vsign, sign_product;
int assign_wp = 0;
mpi_ptr_t tmp_limb = NULL;
- int err;
+ int err = 0;
if (u->nlimbs < v->nlimbs) {
/* Swap U and V. */
--
2.34.1
On Fri, Sep 13, 2024 at 10:07:42PM +0800, Qianqiang Liu wrote: > The "err" variable may be returned without an initialized value. > > Fixes: 8e3a67f2de87 ("crypto: lib/mpi - Add error checks to extension") > Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com> > --- > lib/crypto/mpi/mpi-mul.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/crypto/mpi/mpi-mul.c b/lib/crypto/mpi/mpi-mul.c > index 892a246216b9..7e6ff1ce3e9b 100644 > --- a/lib/crypto/mpi/mpi-mul.c > +++ b/lib/crypto/mpi/mpi-mul.c > @@ -21,7 +21,7 @@ int mpi_mul(MPI w, MPI u, MPI v) > int usign, vsign, sign_product; > int assign_wp = 0; > mpi_ptr_t tmp_limb = NULL; > - int err; > + int err = 0; > > if (u->nlimbs < v->nlimbs) { > /* Swap U and V. */ > -- > 2.34.1 Could you please review this patch? -- Best, Qianqiang Liu
On Sat, Sep 14, 2024 at 08:53:30AM +0800, Qianqiang Liu wrote: > On Fri, Sep 13, 2024 at 10:07:42PM +0800, Qianqiang Liu wrote: > > The "err" variable may be returned without an initialized value. > > > > Fixes: 8e3a67f2de87 ("crypto: lib/mpi - Add error checks to extension") > > Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com> > > --- > > lib/crypto/mpi/mpi-mul.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/crypto/mpi/mpi-mul.c b/lib/crypto/mpi/mpi-mul.c > > index 892a246216b9..7e6ff1ce3e9b 100644 > > --- a/lib/crypto/mpi/mpi-mul.c > > +++ b/lib/crypto/mpi/mpi-mul.c > > @@ -21,7 +21,7 @@ int mpi_mul(MPI w, MPI u, MPI v) > > int usign, vsign, sign_product; > > int assign_wp = 0; > > mpi_ptr_t tmp_limb = NULL; > > - int err; > > + int err = 0; > > > > if (u->nlimbs < v->nlimbs) { > > /* Swap U and V. */ > > -- > > 2.34.1 > > Could you please review this patch? Patch applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Qianqiang Liu <qianqiang.liu@163.com> writes: > On Fri, Sep 13, 2024 at 10:07:42PM +0800, Qianqiang Liu wrote: >> The "err" variable may be returned without an initialized value. >> >> Fixes: 8e3a67f2de87 ("crypto: lib/mpi - Add error checks to extension") >> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com> Thanks for the patch. You can update the commit message and subject line to be more specific. *** example Subject: crypto: lib/mpi - Fix return of uninitailized variable err If no error occurs, "err" variable will be returned with uninitialized value, which is actually a success case scenario and return value should have been zero. *** This makes the need of entire fix more clear. I think currently no body is checking return value of this function as this is recent introduction or this would have failed. Kamlesh
Kamlesh Gurudasani <kamlesh@ti.com> writes: > Qianqiang Liu <qianqiang.liu@163.com> writes: > >> On Fri, Sep 13, 2024 at 10:07:42PM +0800, Qianqiang Liu wrote: >>> The "err" variable may be returned without an initialized value. >>> >>> Fixes: 8e3a67f2de87 ("crypto: lib/mpi - Add error checks to extension") >>> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com> > Thanks for the patch. > > You can update the commit message and subject line to be more specific. > > *** > example > Subject: crypto: lib/mpi - Fix return of uninitailized variable err > > If no error occurs, "err" variable will be returned with uninitialized > value, which is actually a success case scenario and return value should > have been zero. My bad when I looked in detail, if (!vsize) wsize = 0; if this condition is true, mpihelp_mul will never be called, leaving err uninitialized, not sure if that is success case scenario or failure. If that is success case scenario, this fix will do the work, if it is failure case scenario, appropriate return value should also needed to be err. In any case, the commit message that I have mentioned will not be correct, so please scratch that. Kamlesh
© 2016 - 2024 Red Hat, Inc.