Re: [PATCH] crypto: lib/mpi - Fix an "Uninitialized scalar variable" issue

From: Kamlesh Gurudasani
Date: Sun Sep 15 2024 - 12:46:06 EST


Kamlesh Gurudasani <kamlesh@xxxxxx> writes:

> Qianqiang Liu <qianqiang.liu@xxxxxxx> 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@xxxxxxx>
> 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