lkml.org 
[lkml]   [2015]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] iio: hid-sensors: Fix memory leak on failure path in hid_prox_probe()
Date
If prox_parse_report() fails, memory allocated for channels is not
deallocated, since it is still in local variable channels
while kfree() is called with indio_dev->channels.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/iio/light/hid-sensor-prox.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index 91ecc46ffeaa..d0d188108a11 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -281,8 +281,9 @@ static int hid_prox_probe(struct platform_device *pdev)
ret = prox_parse_report(pdev, hsdev, channels,
HID_USAGE_SENSOR_PROX, prox_state);
if (ret) {
+ kfree(channels);
dev_err(&pdev->dev, "failed to setup attributes\n");
- goto error_free_dev_mem;
+ return ret;
}

indio_dev->channels = channels;
--
1.9.1


\
 
 \ /
  Last update: 2015-05-07 00:21    [from the cache]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site