linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: imu: adis16400: fix memory leak
@ 2019-09-18 17:03 Navid Emamdoost
  2019-09-19  6:52 ` Ardelean, Alexandru
  0 siblings, 1 reply; 5+ messages in thread
From: Navid Emamdoost @ 2019-09-18 17:03 UTC (permalink / raw)
  Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Lars-Peter Clausen,
	Michael Hennerich, Stefan Popa, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio, linux-kernel

In adis_update_scan_mode_burst, if adis->buffer allocation fails release
the adis->xfer.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/iio/imu/adis_buffer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
index 9ac8356d9a95..1dbe25572a39 100644
--- a/drivers/iio/imu/adis_buffer.c
+++ b/drivers/iio/imu/adis_buffer.c
@@ -35,8 +35,10 @@ static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,
 		return -ENOMEM;
 
 	adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
-	if (!adis->buffer)
+	if (!adis->buffer) {
+		kfree(adis->xfer);
 		return -ENOMEM;
+	}
 
 	tx = adis->buffer + burst_length;
 	tx[0] = ADIS_READ_REG(adis->burst->reg_cmd);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-21 18:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 17:03 [PATCH] iio: imu: adis16400: fix memory leak Navid Emamdoost
2019-09-19  6:52 ` Ardelean, Alexandru
2019-09-19 15:56   ` [PATCH v2] " Navid Emamdoost
2019-09-20  6:46     ` Ardelean, Alexandru
2019-09-21 18:15       ` Jonathan Cameron

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).