lkml.org 
[lkml]   [2012]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] edac_mc: fix kfree calls in the error path
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);
}

\
 
 \ /
  Last update: 2012-08-10 12:03    [W:0.074 / U:0.736 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site