From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Ben Skeggs <bskeggs@redhat.com>, David Airlie <airlied@linux.ie>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
nouveau@lists.freedesktop.org,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH] drm/nouveau/iccsense: fix memory leak
Date: Sun, 12 Jun 2016 15:56:34 +0100 [thread overview]
Message-ID: <1465743394-6027-1-git-send-email-sudipm.mukherjee@gmail.com> (raw)
In the for loop we are allocating the memory for rail everytime but
in some cases we use "continue" and in those cases the memory already
allocated for rail is leaked and we again allocate new memory for it.
Lets free the memory before continuing with the loop.
Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
---
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index 323c79a..756ff07 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -290,21 +290,28 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
switch (sensor->type) {
case NVBIOS_EXTDEV_INA209:
- if (r->rail != 0)
+ if (r->rail != 0) {
+ kfree(rail);
continue;
+ }
rail->read = nvkm_iccsense_ina209_read;
break;
case NVBIOS_EXTDEV_INA219:
- if (r->rail != 0)
+ if (r->rail != 0) {
+ kfree(rail);
continue;
+ }
rail->read = nvkm_iccsense_ina219_read;
break;
case NVBIOS_EXTDEV_INA3221:
- if (r->rail >= 3)
+ if (r->rail >= 3) {
+ kfree(rail);
continue;
+ }
rail->read = nvkm_iccsense_ina3221_read;
break;
default:
+ kfree(rail);
continue;
}
--
1.9.1
reply other threads:[~2016-06-12 14:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1465743394-6027-1-git-send-email-sudipm.mukherjee@gmail.com \
--to=sudipm.mukherjee@gmail.com \
--cc=airlied@linux.ie \
--cc=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nouveau@lists.freedesktop.org \
/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
all inboxes | Powered by JetHome®