Explorar el Código

amd64_edac: Fix potential memleak

We check the pointers together but at least one of them could be invalid
due to failed allocation. Since we cannot continue if either of the two
allocations has failed, exit early by freeing them both.

Cc: <stable@kernel.org> # 38.x
Reported-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Borislav Petkov hace 14 años
padre
commit
a9f0fbe2bb
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      drivers/edac/amd64_edac.c

+ 1 - 1
drivers/edac/amd64_edac.c

@@ -2679,7 +2679,7 @@ static int __init amd64_edac_init(void)
 	mcis	  = kzalloc(amd_nb_num() * sizeof(mcis[0]), GFP_KERNEL);
 	mcis	  = kzalloc(amd_nb_num() * sizeof(mcis[0]), GFP_KERNEL);
 	ecc_stngs = kzalloc(amd_nb_num() * sizeof(ecc_stngs[0]), GFP_KERNEL);
 	ecc_stngs = kzalloc(amd_nb_num() * sizeof(ecc_stngs[0]), GFP_KERNEL);
 	if (!(mcis && ecc_stngs))
 	if (!(mcis && ecc_stngs))
-		goto err_ret;
+		goto err_free;
 
 
 	msrs = msrs_alloc();
 	msrs = msrs_alloc();
 	if (!msrs)
 	if (!msrs)