Re: [bug report] lib/mpi: Extend the MPI library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux