All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iw: Fix memory leak in error path
@ 2015-10-09 14:52 Ola Olsson
  2015-10-12  7:23 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Ola Olsson @ 2015-10-09 14:52 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Ola Olsson, Ola Olsson

The leak is present if malloc fails after requesting
a scan with ies or meshid as input.

Signed-off-by: Ola Olsson <ola.olsson@sonymobile.com>
---
 scan.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scan.c b/scan.c
index 8197679..d3c7d98 100644
--- a/scan.c
+++ b/scan.c
@@ -446,8 +446,11 @@ static int handle_scan(struct nl80211_state *state,
 
 	if (ies || meshid) {
 		tmpies = (unsigned char *) malloc(ies_len + meshid_len);
-		if (!tmpies)
+		if (!tmpies) {
+			free(ies);
+			free(meshid);
 			goto nla_put_failure;
+		}
 		if (ies) {
 			memcpy(tmpies, ies, ies_len);
 			free(ies);
-- 
1.7.9.5


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

* Re: [PATCH] iw: Fix memory leak in error path
  2015-10-09 14:52 [PATCH] iw: Fix memory leak in error path Ola Olsson
@ 2015-10-12  7:23 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2015-10-12  7:23 UTC (permalink / raw)
  To: Ola Olsson; +Cc: linux-wireless, Ola Olsson

On Fri, 2015-10-09 at 16:52 +0200, Ola Olsson wrote:
> The leak is present if malloc fails after requesting
> a scan with ies or meshid as input.
> 
Applied, thanks!

johannes

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

end of thread, other threads:[~2015-10-12  7:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-09 14:52 [PATCH] iw: Fix memory leak in error path Ola Olsson
2015-10-12  7:23 ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.