From d209181d96ff90a2a027694934c1d22da22140a5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 7 Mar 2016 11:51:24 -0500 Subject: [PATCH] Manage: Manage_add(): Fix memory leak sysfs_read() allocates and populates a struct mdinfo, however the code forgot to free it again, before dropping the reference to the pointer. Reviewed-by: NeilBrown Signed-off-by: Jes Sorensen --- Manage.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Manage.c b/Manage.c index e3d46f3..5308260 100644 --- a/Manage.c +++ b/Manage.c @@ -944,10 +944,13 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv, } if (strncmp(mdp->sysfs_array_state, "readonly", 8) != 0) { + sysfs_free(mdp); pr_err("%s is not readonly, cannot add journal.\n", devname); return -1; } + sysfs_free(mdp); + tst->ss->getinfo_super(tst, &mdi, NULL); if (mdi.journal_device_required == 0) { pr_err("%s does not support journal device.\n", devname);