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

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

 



Hi, Dan Carpenter,

On 9/15/23 3:21 PM, 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/mpiutil.c:202 mpi_copy() error: potential null dereference 'b'.  (mpi_alloc returns null)
lib/crypto/mpi/mpiutil.c:224 mpi_alloc_like() error: potential null dereference 'b'.  (mpi_alloc returns null)
lib/crypto/mpi/mpiutil.c:258 mpi_set() error: potential null dereference 'w'.  (<unknown> returns null)
lib/crypto/mpi/mpiutil.c:277 mpi_set_ui() error: potential null dereference 'w'.  (<unknown> returns null)
lib/crypto/mpi/mpiutil.c:289 mpi_alloc_set_ui() error: potential null dereference 'w'.  (mpi_alloc returns null)

lib/crypto/mpi/mpiutil.c
     195 MPI mpi_copy(MPI a)
     196 {
     197         int i;
     198         MPI b;
     199
     200         if (a) {
     201                 b = mpi_alloc(a->nlimbs);

Allocations can fail.

--> 202                 b->nlimbs = a->nlimbs;
     203                 b->sign = a->sign;
     204                 b->flags = a->flags;
     205                 b->flags &= ~(16|32); /* Reset the immutable and constant flags. */
     206                 for (i = 0; i < b->nlimbs; i++)
     207                         b->d[i] = a->d[i];
     208         } else
     209                 b = NULL;
     210         return b;
     211 }

regards,
dan carpenter

Thanks for reminding me, these are some remaining issues that needs more
modifications. I will take the time to fix them.

Cheers,
Tianjia



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