From: Fengguang Wu <fengguang.wu@intel.com> To: Mauro Carvalho Chehab <mchehab@redhat.com> Cc: Dave Peterson <dsp@llnl.gov>, kernel-janitors@vger.kernel.org, Doug Thompson <dougthompson@xmission.com>, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] edac_mc: fix kfree calls in the error path Date: Fri, 10 Aug 2012 17:22:23 +0800 [thread overview] Message-ID: <20120810092223.GA27375@localhost> (raw) In-Reply-To: <5023F360.2050409@redhat.com> 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); }
WARNING: multiple messages have this Message-ID (diff)
From: Fengguang Wu <fengguang.wu@intel.com> To: Mauro Carvalho Chehab <mchehab@redhat.com> Cc: Dave Peterson <dsp@llnl.gov>, kernel-janitors@vger.kernel.org, Doug Thompson <dougthompson@xmission.com>, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] edac_mc: fix kfree calls in the error path Date: Fri, 10 Aug 2012 09:22:23 +0000 [thread overview] Message-ID: <20120810092223.GA27375@localhost> (raw) In-Reply-To: <5023F360.2050409@redhat.com> 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); }
next prev parent reply other threads:[~2012-08-10 9:22 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-08-09 13:54 Fengguang Wu 2012-08-09 17:29 ` Mauro Carvalho Chehab 2012-08-10 9:22 ` Fengguang Wu [this message] 2012-08-10 9:22 ` [PATCH] edac_mc: fix kfree calls in the error path Fengguang Wu 2012-08-19 4:11 ` [PATCH 0/3] Fix edac_mc crash in e7xxx_edac " Shaun Ruffell 2012-08-19 4:11 ` [PATCH 1/3] edac_mc: fix kfree calls in the " Shaun Ruffell 2012-08-19 4:11 ` [PATCH 2/3] edac: edac_mc_free() cannot assume mem_ctl_info is registered in sysfs Shaun Ruffell 2012-08-19 4:11 ` [PATCH 3/3] edac: edac_mc no longer deals with kobjects directly Shaun Ruffell 2012-09-08 18:49 ` [PATCH 0/3] Fix edac_mc crash in e7xxx_edac error path Shaun Ruffell 2012-09-14 17:58 ` [PATCH v2 " Shaun Ruffell 2012-09-14 17:58 ` [PATCH v2 1/3] edac_mc: fix kfree calls in the " Shaun Ruffell 2012-09-14 18:01 ` Shaun Ruffell 2012-09-14 17:58 ` [PATCH v2 2/3] edac: edac_mc_free() cannot assume mem_ctl_info is registered in sysfs Shaun Ruffell 2012-09-14 17:58 ` [PATCH v2 3/3] edac: edac_mc no longer deals with kobjects directly Shaun Ruffell
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20120810092223.GA27375@localhost \ --to=fengguang.wu@intel.com \ --cc=dougthompson@xmission.com \ --cc=dsp@llnl.gov \ --cc=kernel-janitors@vger.kernel.org \ --cc=linux-edac@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mchehab@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.