Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib/mpi: Add the return value check of kcalloc()

Add the return value check of kcalloc() to avoid potential
NULL ptr dereference.

Fixes: a8ea8bdd9df9 ("lib/mpi: Extend the MPI library")
Signed-off-by: Zizhuang Deng <sunsetdzz@gmail.com>
Reviewed-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Zizhuang Deng and committed by
Herbert Xu
dd827abe 4cab5dfd

+2
+2
lib/mpi/mpi-mod.c
··· 40 40 41 41 mpi_normalize(m); 42 42 ctx = kcalloc(1, sizeof(*ctx), GFP_KERNEL); 43 + if (!ctx) 44 + return NULL; 43 45 44 46 if (copy) { 45 47 ctx->m = mpi_copy(m);