Commit fe0e94c5a7e5335ba0d200e7d3e26e9f80cda4b1

Authored by Dan Carpenter
Committed by James Morris
1 parent de35353375

mpi/mpi-mpow: NULL dereference on allocation failure

We can't call mpi_free() on the elements if the first kzalloc() fails.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: James Morris <jmorris@namei.org>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

... ... @@ -73,7 +73,7 @@
73 73  
74 74 G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
75 75 if (!G)
76   - goto nomem;
  76 + goto err_out;
77 77  
78 78 /* and calculate */
79 79 tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
... ... @@ -129,6 +129,7 @@
129 129 for (i = 0; i < (1 << k); i++)
130 130 mpi_free(G[i]);
131 131 kfree(G);
  132 +err_out:
132 133 return rc;
133 134 }