Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1706475

[PATCH] staging: bcm2835-audio: Fix memory corruption

From Phil Elwell <phil@raspberrypi.org>
Newsgroups linux.kernel
Subject [PATCH] staging: bcm2835-audio: Fix memory corruption
Date 2017-08-08 14:20 +0200
Message-ID <ucbEn-8gS-27@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


I'm all for fixing memory leaks, but freeing a block while it is still
being used is a recipe for hard-to-debug kernel exceptions.

1) There is already a vchi method for freeing the instance, so use it.
2) Only call it on error, and then only before initted is false.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Fixes: 0adbfd4694c2 ("staging: bcm2835-audio: fix memory leak in bcm2835_audio_open_connection()")
---
 drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
index 5f3d8f2..89f96f3 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
@@ -409,6 +409,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
 			LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n",
 				__func__, ret);
 
+			vchi_disconnect(vchi_instance);
 			ret = -EIO;
 			goto err_free_mem;
 		}
@@ -431,7 +432,6 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
 	LOG_DBG(" success !\n");
 	ret = 0;
 err_free_mem:
-	kfree(vchi_instance);
 
 	return ret;
 }
-- 
1.9.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] staging: bcm2835-audio: Fix memory corruption Phil Elwell <phil@raspberrypi.org> - 2017-08-08 14:20 +0200
  Re: [PATCH] staging: bcm2835-audio: Fix memory corruption Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-10 12:30 +0200
    Re: [PATCH] staging: bcm2835-audio: Fix memory corruption Phil Elwell <phil@raspberrypi.org> - 2017-08-10 13:00 +0200
      Re: [PATCH] staging: bcm2835-audio: Fix memory corruption Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-10 13:10 +0200
      Re: [PATCH] staging: bcm2835-audio: Fix memory corruption Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-10 13:30 +0200
        Re: [PATCH] staging: bcm2835-audio: Fix memory corruption Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-10 13:40 +0200
        Re: [PATCH] staging: bcm2835-audio: Fix memory corruption Phil Elwell <phil@raspberrypi.org> - 2017-08-10 15:30 +0200
          Re: [PATCH] staging: bcm2835-audio: Fix memory corruption Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-10 16:10 +0200

csiph-web