Skip to content

Commit

Permalink
lib/mpi: Add the return value check of kcalloc()
Browse files Browse the repository at this point in the history
Add the return value check of kcalloc() to avoid potential
NULL ptr dereference.

Fixes: a8ea8bd ("lib/mpi: Extend the MPI library")
Signed-off-by: Zizhuang Deng <[email protected]>
Reviewed-by: Tianjia Zhang <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
enderdzz authored and herbertx committed Jan 7, 2022
1 parent 4cab5df commit dd827ab
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/mpi/mpi-mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ mpi_barrett_t mpi_barrett_init(MPI m, int copy)

mpi_normalize(m);
ctx = kcalloc(1, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return NULL;

if (copy) {
ctx->m = mpi_copy(m);
Expand Down

0 comments on commit dd827ab

Please sign in to comment.