* [PATCH] iw: Memory leak in error condition @ 2015-09-30 23:01 Ola Olsson 2015-09-30 23:16 ` James Cameron 0 siblings, 1 reply; 7+ messages in thread From: Ola Olsson @ 2015-09-30 23:01 UTC (permalink / raw) To: johannes; +Cc: linux-wireless >From 5239e8e9aa79a131b716398efbf7a1203decbd9b Mon Sep 17 00:00:00 2001 From: Ola Olsson <ola.olsson@sonymobile.com> Date: Thu, 1 Oct 2015 00:43:06 +0200 Subject: [PATCH] iw: Memory leak in error condition Signed-off-by: Ola Olsson <ola.olsson@sonymobile.com> --- scan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scan.c b/scan.c index e959c1b..f248981 100644 --- a/scan.c +++ b/scan.c @@ -446,6 +446,8 @@ static int handle_scan(struct nl80211_state *state, if (ies || meshid) { tmpies = (unsigned char *) malloc(ies_len + meshid_len); if (!tmpies) + free(ies); + free(meshid); goto nla_put_failure; if (ies) { memcpy(tmpies, ies, ies_len); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] iw: Memory leak in error condition 2015-09-30 23:01 [PATCH] iw: Memory leak in error condition Ola Olsson @ 2015-09-30 23:16 ` James Cameron 2015-09-30 23:27 ` Ola Olsson 0 siblings, 1 reply; 7+ messages in thread From: James Cameron @ 2015-09-30 23:16 UTC (permalink / raw) To: Ola Olsson; +Cc: johannes, linux-wireless On Thu, Oct 01, 2015 at 01:01:18AM +0200, Ola Olsson wrote: > >From 5239e8e9aa79a131b716398efbf7a1203decbd9b Mon Sep 17 00:00:00 2001 > From: Ola Olsson <ola.olsson@sonymobile.com> > Date: Thu, 1 Oct 2015 00:43:06 +0200 > Subject: [PATCH] iw: Memory leak in error condition Signed-off-by: Ola > Olsson <ola.olsson@sonymobile.com> > > --- > scan.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/scan.c b/scan.c > index e959c1b..f248981 100644 > --- a/scan.c > +++ b/scan.c > @@ -446,6 +446,8 @@ static int handle_scan(struct nl80211_state *state, > if (ies || meshid) { > tmpies = (unsigned char *) malloc(ies_len + meshid_len); > if (!tmpies) > + free(ies); > + free(meshid); > goto nla_put_failure; Braces? { } > if (ies) { > memcpy(tmpies, ies, ies_len); > -- > 1.7.9.5 > -- > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- James Cameron http://quozl.linux.org.au/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iw: Memory leak in error condition 2015-09-30 23:16 ` James Cameron @ 2015-09-30 23:27 ` Ola Olsson 2015-09-30 23:34 ` Julian Calaby 2015-10-08 9:37 ` Johannes Berg 0 siblings, 2 replies; 7+ messages in thread From: Ola Olsson @ 2015-09-30 23:27 UTC (permalink / raw) To: James Cameron; +Cc: Johannes Berg, linux-wireless Oh yes! :) Suddenly valgrind was happy as well. >From 2724dd259f2bf61a2b7c85a70a70fd640a583453 Mon Sep 17 00:00:00 2001 From: Ola Olsson <ola.olsson@sonymobile.com> Date: Thu, 1 Oct 2015 00:43:06 +0200 Subject: [PATCH] iw: Memory leak in error condition 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 e959c1b..f3441a7 100644 --- a/scan.c +++ b/scan.c @@ -445,8 +445,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 On Thu, Oct 1, 2015 at 1:16 AM, James Cameron <quozl@laptop.org> wrote: > On Thu, Oct 01, 2015 at 01:01:18AM +0200, Ola Olsson wrote: >> >From 5239e8e9aa79a131b716398efbf7a1203decbd9b Mon Sep 17 00:00:00 2001 >> From: Ola Olsson <ola.olsson@sonymobile.com> >> Date: Thu, 1 Oct 2015 00:43:06 +0200 >> Subject: [PATCH] iw: Memory leak in error condition Signed-off-by: Ola >> Olsson <ola.olsson@sonymobile.com> >> >> --- >> scan.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/scan.c b/scan.c >> index e959c1b..f248981 100644 >> --- a/scan.c >> +++ b/scan.c >> @@ -446,6 +446,8 @@ static int handle_scan(struct nl80211_state *state, >> if (ies || meshid) { >> tmpies = (unsigned char *) malloc(ies_len + meshid_len); >> if (!tmpies) >> + free(ies); >> + free(meshid); >> goto nla_put_failure; > > Braces? { } > > >> if (ies) { >> memcpy(tmpies, ies, ies_len); >> -- >> 1.7.9.5 >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- > James Cameron > http://quozl.linux.org.au/ ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] iw: Memory leak in error condition 2015-09-30 23:27 ` Ola Olsson @ 2015-09-30 23:34 ` Julian Calaby 2015-09-30 23:39 ` Ola Olsson 2015-10-08 9:37 ` Johannes Berg 1 sibling, 1 reply; 7+ messages in thread From: Julian Calaby @ 2015-09-30 23:34 UTC (permalink / raw) To: Ola Olsson; +Cc: James Cameron, Johannes Berg, linux-wireless Hi Ola, On Thu, Oct 1, 2015 at 9:27 AM, Ola Olsson <ola1olsson@gmail.com> wrote: > Oh yes! :) > Suddenly valgrind was happy as well. > > From 2724dd259f2bf61a2b7c85a70a70fd640a583453 Mon Sep 17 00:00:00 2001 > From: Ola Olsson <ola.olsson@sonymobile.com> > Date: Thu, 1 Oct 2015 00:43:06 +0200 > Subject: [PATCH] iw: Memory leak in error condition 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 e959c1b..f3441a7 100644 > --- a/scan.c > +++ b/scan.c > @@ -445,8 +445,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) { free() doesn't set it to "null" or anything like that, so isn't the line above a use-after-free? > memcpy(tmpies, ies, ies_len); > free(ies); > -- > 1.7.9.5 > > On Thu, Oct 1, 2015 at 1:16 AM, James Cameron <quozl@laptop.org> wrote: >> On Thu, Oct 01, 2015 at 01:01:18AM +0200, Ola Olsson wrote: >>> >From 5239e8e9aa79a131b716398efbf7a1203decbd9b Mon Sep 17 00:00:00 2001 >>> From: Ola Olsson <ola.olsson@sonymobile.com> >>> Date: Thu, 1 Oct 2015 00:43:06 +0200 >>> Subject: [PATCH] iw: Memory leak in error condition Signed-off-by: Ola >>> Olsson <ola.olsson@sonymobile.com> >>> >>> --- >>> scan.c | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/scan.c b/scan.c >>> index e959c1b..f248981 100644 >>> --- a/scan.c >>> +++ b/scan.c >>> @@ -446,6 +446,8 @@ static int handle_scan(struct nl80211_state *state, >>> if (ies || meshid) { >>> tmpies = (unsigned char *) malloc(ies_len + meshid_len); >>> if (!tmpies) >>> + free(ies); >>> + free(meshid); >>> goto nla_put_failure; >> >> Braces? { } >> >> >>> if (ies) { >>> memcpy(tmpies, ies, ies_len); >>> -- >>> 1.7.9.5 >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >> -- >> James Cameron >> http://quozl.linux.org.au/ > -- > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Julian Calaby Email: julian.calaby@gmail.com Profile: http://www.google.com/profiles/julian.calaby/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iw: Memory leak in error condition 2015-09-30 23:34 ` Julian Calaby @ 2015-09-30 23:39 ` Ola Olsson 2015-09-30 23:40 ` Julian Calaby 0 siblings, 1 reply; 7+ messages in thread From: Ola Olsson @ 2015-09-30 23:39 UTC (permalink / raw) To: Julian Calaby; +Cc: James Cameron, Johannes Berg, linux-wireless I guess not since there is a goto statement in between. Please correct me if I am wrong. /Ola On Thu, Oct 1, 2015 at 1:34 AM, Julian Calaby <julian.calaby@gmail.com> wrote: > Hi Ola, > > On Thu, Oct 1, 2015 at 9:27 AM, Ola Olsson <ola1olsson@gmail.com> wrote: >> Oh yes! :) >> Suddenly valgrind was happy as well. >> >> From 2724dd259f2bf61a2b7c85a70a70fd640a583453 Mon Sep 17 00:00:00 2001 >> From: Ola Olsson <ola.olsson@sonymobile.com> >> Date: Thu, 1 Oct 2015 00:43:06 +0200 >> Subject: [PATCH] iw: Memory leak in error condition 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 e959c1b..f3441a7 100644 >> --- a/scan.c >> +++ b/scan.c >> @@ -445,8 +445,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) { > > free() doesn't set it to "null" or anything like that, so isn't the > line above a use-after-free? > >> memcpy(tmpies, ies, ies_len); >> free(ies); >> -- >> 1.7.9.5 >> >> On Thu, Oct 1, 2015 at 1:16 AM, James Cameron <quozl@laptop.org> wrote: >>> On Thu, Oct 01, 2015 at 01:01:18AM +0200, Ola Olsson wrote: >>>> >From 5239e8e9aa79a131b716398efbf7a1203decbd9b Mon Sep 17 00:00:00 2001 >>>> From: Ola Olsson <ola.olsson@sonymobile.com> >>>> Date: Thu, 1 Oct 2015 00:43:06 +0200 >>>> Subject: [PATCH] iw: Memory leak in error condition Signed-off-by: Ola >>>> Olsson <ola.olsson@sonymobile.com> >>>> >>>> --- >>>> scan.c | 2 ++ >>>> 1 file changed, 2 insertions(+) >>>> >>>> diff --git a/scan.c b/scan.c >>>> index e959c1b..f248981 100644 >>>> --- a/scan.c >>>> +++ b/scan.c >>>> @@ -446,6 +446,8 @@ static int handle_scan(struct nl80211_state *state, >>>> if (ies || meshid) { >>>> tmpies = (unsigned char *) malloc(ies_len + meshid_len); >>>> if (!tmpies) >>>> + free(ies); >>>> + free(meshid); >>>> goto nla_put_failure; >>> >>> Braces? { } >>> >>> >>>> if (ies) { >>>> memcpy(tmpies, ies, ies_len); >>>> -- >>>> 1.7.9.5 >>>> -- >>>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in >>>> the body of a message to majordomo@vger.kernel.org >>>> More majordomo info at http://vger.kernel.org/majordomo-info.html >>> >>> -- >>> James Cameron >>> http://quozl.linux.org.au/ >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > -- > Julian Calaby > > Email: julian.calaby@gmail.com > Profile: http://www.google.com/profiles/julian.calaby/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iw: Memory leak in error condition 2015-09-30 23:39 ` Ola Olsson @ 2015-09-30 23:40 ` Julian Calaby 0 siblings, 0 replies; 7+ messages in thread From: Julian Calaby @ 2015-09-30 23:40 UTC (permalink / raw) To: Ola Olsson; +Cc: James Cameron, Johannes Berg, linux-wireless Hi Ola, On Thu, Oct 1, 2015 at 9:39 AM, Ola Olsson <ola1olsson@gmail.com> wrote: > I guess not since there is a goto statement in between. Please correct > me if I am wrong. Oh, wait, you are right. I'm used to goto-free code. Sorry for the noise. Thanks, Julian Calaby > /Ola > > On Thu, Oct 1, 2015 at 1:34 AM, Julian Calaby <julian.calaby@gmail.com> wrote: >> Hi Ola, >> >> On Thu, Oct 1, 2015 at 9:27 AM, Ola Olsson <ola1olsson@gmail.com> wrote: >>> Oh yes! :) >>> Suddenly valgrind was happy as well. >>> >>> From 2724dd259f2bf61a2b7c85a70a70fd640a583453 Mon Sep 17 00:00:00 2001 >>> From: Ola Olsson <ola.olsson@sonymobile.com> >>> Date: Thu, 1 Oct 2015 00:43:06 +0200 >>> Subject: [PATCH] iw: Memory leak in error condition 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 e959c1b..f3441a7 100644 >>> --- a/scan.c >>> +++ b/scan.c >>> @@ -445,8 +445,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) { >> >> free() doesn't set it to "null" or anything like that, so isn't the >> line above a use-after-free? >> >>> memcpy(tmpies, ies, ies_len); >>> free(ies); >>> -- >>> 1.7.9.5 >>> >>> On Thu, Oct 1, 2015 at 1:16 AM, James Cameron <quozl@laptop.org> wrote: >>>> On Thu, Oct 01, 2015 at 01:01:18AM +0200, Ola Olsson wrote: >>>>> >From 5239e8e9aa79a131b716398efbf7a1203decbd9b Mon Sep 17 00:00:00 2001 >>>>> From: Ola Olsson <ola.olsson@sonymobile.com> >>>>> Date: Thu, 1 Oct 2015 00:43:06 +0200 >>>>> Subject: [PATCH] iw: Memory leak in error condition Signed-off-by: Ola >>>>> Olsson <ola.olsson@sonymobile.com> >>>>> >>>>> --- >>>>> scan.c | 2 ++ >>>>> 1 file changed, 2 insertions(+) >>>>> >>>>> diff --git a/scan.c b/scan.c >>>>> index e959c1b..f248981 100644 >>>>> --- a/scan.c >>>>> +++ b/scan.c >>>>> @@ -446,6 +446,8 @@ static int handle_scan(struct nl80211_state *state, >>>>> if (ies || meshid) { >>>>> tmpies = (unsigned char *) malloc(ies_len + meshid_len); >>>>> if (!tmpies) >>>>> + free(ies); >>>>> + free(meshid); >>>>> goto nla_put_failure; >>>> >>>> Braces? { } >>>> >>>> >>>>> if (ies) { >>>>> memcpy(tmpies, ies, ies_len); >>>>> -- >>>>> 1.7.9.5 >>>>> -- >>>>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in >>>>> the body of a message to majordomo@vger.kernel.org >>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html >>>> >>>> -- >>>> James Cameron >>>> http://quozl.linux.org.au/ >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >> >> >> -- >> Julian Calaby >> >> Email: julian.calaby@gmail.com >> Profile: http://www.google.com/profiles/julian.calaby/ -- Julian Calaby Email: julian.calaby@gmail.com Profile: http://www.google.com/profiles/julian.calaby/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iw: Memory leak in error condition 2015-09-30 23:27 ` Ola Olsson 2015-09-30 23:34 ` Julian Calaby @ 2015-10-08 9:37 ` Johannes Berg 1 sibling, 0 replies; 7+ messages in thread From: Johannes Berg @ 2015-10-08 9:37 UTC (permalink / raw) To: Ola Olsson, James Cameron; +Cc: linux-wireless On Thu, 2015-10-01 at 01:27 +0200, Ola Olsson wrote: > Oh yes! :) > Suddenly valgrind was happy as well. > > From 2724dd259f2bf61a2b7c85a70a70fd640a583453 Mon Sep 17 00:00:00 > 2001 > From: Ola Olsson <ola.olsson@sonymobile.com> > Date: Thu, 1 Oct 2015 00:43:06 +0200 > Subject: [PATCH] iw: Memory leak in error condition Signed-off-by: > Ola Olsson > <ola.olsson@sonymobile.com> This got picked up as a new patch by patchwork, but please resend. As I mentioned on the other patch, you have whitespace issues (tabs replaced by space, so the patch doesn't apply) Also, on this particular patch you forgot the Signed-off-by. Please also reword the subject to indicate that you fixed something, it seems a bit strange to me to write just "memory leak" :) Your "MHZ" patch also has the same whitespace issues, while the if.h patch applied fine (though it wasn't changing any indented code, so whitespace wouldn't have mattered) Please resend this patch, the return values one and the MHz one. Thanks, johannes > --- > scan.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/scan.c b/scan.c > index e959c1b..f3441a7 100644 > --- a/scan.c > +++ b/scan.c > @@ -445,8 +445,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); ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-10-08 9:37 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-09-30 23:01 [PATCH] iw: Memory leak in error condition Ola Olsson 2015-09-30 23:16 ` James Cameron 2015-09-30 23:27 ` Ola Olsson 2015-09-30 23:34 ` Julian Calaby 2015-09-30 23:39 ` Ola Olsson 2015-09-30 23:40 ` Julian Calaby 2015-10-08 9:37 ` Johannes Berg
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).