linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] iio:kfifo: Fix memory leak
@ 2013-10-15  8:30 Lars-Peter Clausen
  2013-10-15  8:30 ` [PATCH v2 2/4] iio:kfifo: Protect against concurrent access from userspace Lars-Peter Clausen
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Lars-Peter Clausen @ 2013-10-15  8:30 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

We need to free the kfifo when we release the buffer, otherwise the fifos memory
will be leaked.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

---
New in v2

Btw. This is all against togreg, since it is probably already to late for
fixes-togreg.
---
 drivers/iio/kfifo_buf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
index b4ac55a..ce51092 100644
--- a/drivers/iio/kfifo_buf.c
+++ b/drivers/iio/kfifo_buf.c
@@ -132,7 +132,10 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
 
 static void iio_kfifo_buffer_release(struct iio_buffer *buffer)
 {
-	kfree(iio_to_kfifo(buffer));
+	struct iio_kfifo *kf = iio_to_kfifo(buffer);
+
+	kfifo_free(&kf->kf);
+	kfree(kf);
 }
 
 static const struct iio_buffer_access_funcs kfifo_access_funcs = {
-- 
1.8.0


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

end of thread, other threads:[~2013-10-15 17:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15  8:30 [PATCH v2 1/4] iio:kfifo: Fix memory leak Lars-Peter Clausen
2013-10-15  8:30 ` [PATCH v2 2/4] iio:kfifo: Protect against concurrent access from userspace Lars-Peter Clausen
2013-10-15 18:19   ` Jonathan Cameron
2013-10-15  8:30 ` [PATCH v2 3/4] iio:kfifo: Empty buffer on update Lars-Peter Clausen
2013-10-15 18:20   ` Jonathan Cameron
2013-10-15  8:30 ` [PATCH v2 4/4] iio:kfifo: Set update_needed to false after allocating a new buffer Lars-Peter Clausen
2013-10-15 18:20   ` Jonathan Cameron
2013-10-15 18:19 ` [PATCH v2 1/4] iio:kfifo: Fix memory leak 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).