[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-crypto-vger
Subject:    Re: [bug report] lib/mpi: Extend the MPI library
From:       Dan Carpenter <dan.carpenter () linaro ! org>
Date:       2023-10-30 9:25:13
Message-ID: 9efa9c91-52a7-4535-b0ff-d3e501316e48 () kadam ! mountain
[Download RAW message or body]

On Mon, Oct 30, 2023 at 12:03:38PM +0300, Dan Carpenter wrote:
> Hello Tianjia Zhang,
> 
> The patch a8ea8bdd9df9: "lib/mpi: Extend the MPI library" from Sep
> 21, 2020 (linux-next), leads to the following Smatch static checker
> warning:
> 
> 	lib/crypto/mpi/mpi-div.c:46 mpi_fdiv_q()
> 	error: potential null dereference 'tmp'.  (mpi_alloc returns null)
> 
> lib/crypto/mpi/mpi-div.c
>     43 void mpi_fdiv_q(MPI quot, MPI dividend, MPI divisor)
>     44 {
>     45         MPI tmp = mpi_alloc(mpi_get_nlimbs(quot));
>                    ^^^^^^^^^^^^^^^
> Check for failure?

By the way, in the other thread we discuessed if added a NULL check was
required when the code basically "works fine" as is.  In this case the
allocation is larger and must be checked.

regards,
dan carpenter


> 
> --> 46         mpi_fdiv_qr(quot, tmp, dividend, divisor);
>     47         mpi_free(tmp);
>     48 }
> 
> regards,
> dan carpenter
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic