From: Robert Richter <rrichter@marvell.com>
To: Borislav Petkov <bp@alien8.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Tony Luck <tony.luck@intel.com>
Cc: James Morse <james.morse@arm.com>,
Aristeu Rozanski <aris@redhat.com>,
Robert Richter <rrichter@marvell.com>,
<linux-edac@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: [PATCH v3 3/4] EDAC/sysfs: Remove csrow objects on errors
Date: Wed, 12 Feb 2020 13:03:39 +0100 [thread overview]
Message-ID: <20200212120340.4764-4-rrichter@marvell.com> (raw)
In-Reply-To: <20200212120340.4764-1-rrichter@marvell.com>
All created csrow objects must be removed in the error path of
edac_create_csrow_objects(). The objects have been added as devices.
They need to be removed by doing a device_del() *and* put_device()
call to also free their memory. The misssing put_device() leaves a
memory leak. Use device_unregister() instead of device_del() which
properly unregisters the device doing both.
Fixes: 7adc05d2dc3a ("EDAC/sysfs: Drop device references properly")
Cc: <stable@vger.kernel.org>
Signed-off-by: Robert Richter <rrichter@marvell.com>
---
drivers/edac/edac_mc_sysfs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 1c9c6a7b9f66..c70ec0a306d8 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -444,8 +444,7 @@ static int edac_create_csrow_objects(struct mem_ctl_info *mci)
csrow = mci->csrows[i];
if (!nr_pages_per_csrow(csrow))
continue;
-
- device_del(&mci->csrows[i]->dev);
+ device_unregister(&mci->csrows[i]->dev);
}
return err;
--
2.20.1
next prev parent reply other threads:[~2020-02-12 12:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 12:03 [PATCH v3 0/4] EDAC/mc: Fixes for mci device removal Robert Richter
2020-02-12 12:03 ` [PATCH v3 1/4] Revert parts of "EDAC/mc_sysfs: Make debug messages consistent" Robert Richter
2020-02-12 12:03 ` [PATCH v3 2/4] EDAC/mc: Fix use-after-free and memleaks during device removal Robert Richter
2020-02-12 12:03 ` Robert Richter [this message]
2020-02-12 12:03 ` [PATCH v3 4/4] EDAC/mc: Change mci device removal to use put_device() Robert Richter
2020-02-13 11:05 ` [PATCH v3 0/4] EDAC/mc: Fixes for mci device removal Borislav Petkov
2020-02-13 11:10 ` John Garry
2020-02-13 12:08 ` John Garry
2020-02-13 12:28 ` Borislav Petkov
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=20200212120340.4764-4-rrichter@marvell.com \
--to=rrichter@marvell.com \
--cc=aris@redhat.com \
--cc=bp@alien8.de \
--cc=james.morse@arm.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tony.luck@intel.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).