From: Phil Elwell <phil@raspberrypi.org>
To: Eric Anholt <eric@anholt.net>,
Stefan Wahren <stefan.wahren@i2se.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Florian Fainelli <f.fainelli@gmail.com>,
Aishwarya Pant <aishpant@gmail.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
linux-rpi-kernel@lists.infradead.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Cc: Phil Elwell <phil@raspberrypi.org>
Subject: [PATCH] staging: bcm2835-audio: Fix memory corruption
Date: Tue, 8 Aug 2017 13:05:02 +0100 [thread overview]
Message-ID: <1502193902-87160-1-git-send-email-phil@raspberrypi.org> (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
next reply other threads:[~2017-08-08 12:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-08 12:05 Phil Elwell [this message]
2017-08-10 10:21 ` Dan Carpenter
2017-08-10 10:52 ` Phil Elwell
2017-08-10 11:05 ` Dan Carpenter
2017-08-10 11:24 ` Dan Carpenter
2017-08-10 11:33 ` Dan Carpenter
2017-08-10 13:25 ` Phil Elwell
2017-08-10 14:07 ` Dan Carpenter
2017-08-11 9:57 Phil Elwell
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=1502193902-87160-1-git-send-email-phil@raspberrypi.org \
--to=phil@raspberrypi.org \
--cc=aishpant@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=eric@anholt.net \
--cc=f.fainelli@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=stefan.wahren@i2se.com \
/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
Powered by JetHome