kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] edac_mc: fix kfree calls in the error path
       [not found] ` <5023F360.2050409@redhat.com>
@ 2012-08-10  9:22   ` Fengguang Wu
  0 siblings, 0 replies; only message in thread
From: Fengguang Wu @ 2012-08-10  9:22 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Dave Peterson, kernel-janitors, Doug Thompson, linux-edac,
	linux-kernel

We need to free up memory in this order: 

  free csrows[i]->channels[j]
  free csrows[i]->channels
  free csrows[i]
  free csrows

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
 drivers/edac/edac_mc.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--- linux.orig/drivers/edac/edac_mc.c	2012-08-10 17:16:14.444794060 +0800
+++ linux/drivers/edac/edac_mc.c	2012-08-10 17:16:19.048794169 +0800
@@ -419,14 +419,16 @@ error:
 		kfree(mci->dimms);
 	}
 	if (mci->csrows) {
-		for (chn = 0; chn < tot_channels; chn++) {
-			csr = mci->csrows[chn];
+		for (row = 0; row < tot_csrows; row++) {
+			csr = mci->csrows[row];
 			if (csr) {
-				for (chn = 0; chn < tot_channels; chn++)
-					kfree(csr->channels[chn]);
+				if (csr->channels) {
+					for (chn = 0; chn < tot_channels; chn++)
+						kfree(csr->channels[chn]);
+					kfree(csr->channels);
+				}
 				kfree(csr);
 			}
-			kfree(mci->csrows[i]);
 		}
 		kfree(mci->csrows);
 	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-08-10  9:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20120809135416.GA13100@localhost>
     [not found] ` <5023F360.2050409@redhat.com>
2012-08-10  9:22   ` [PATCH] edac_mc: fix kfree calls in the error path Fengguang Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).