* [PATCH] pwm: lp3943: Fix potential memory leak during request
@ 2014-01-23 21:32 Christian Engelmayer
2014-01-23 22:47 ` Milo Kim
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Christian Engelmayer @ 2014-01-23 21:32 UTC (permalink / raw)
To: Milo Kim, Thierry Reding; +Cc: linux-pwm
Fix a memory leak in the lp3943_pwm_request_map() error handling path.
Make sure already allocated pwm map memory is freed correctly.
Detected by Coverity: CID 1162829.
Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
---
drivers/pwm/pwm-lp3943.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c
index 8a843a0..a40b9c3 100644
--- a/drivers/pwm/pwm-lp3943.c
+++ b/drivers/pwm/pwm-lp3943.c
@@ -52,8 +52,10 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm)
offset = pwm_map->output[i];
/* Return an error if the pin is already assigned */
- if (test_and_set_bit(offset, &lp3943->pin_used))
+ if (test_and_set_bit(offset, &lp3943->pin_used)) {
+ kfree(pwm_map);
return ERR_PTR(-EBUSY);
+ }
}
return pwm_map;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] pwm: lp3943: Fix potential memory leak during request 2014-01-23 21:32 [PATCH] pwm: lp3943: Fix potential memory leak during request Christian Engelmayer @ 2014-01-23 22:47 ` Milo Kim 2014-01-24 16:23 ` Thierry Reding 2014-02-26 15:09 ` Thierry Reding 2 siblings, 0 replies; 6+ messages in thread From: Milo Kim @ 2014-01-23 22:47 UTC (permalink / raw) To: Christian Engelmayer; +Cc: Thierry Reding, linux-pwm On 01/24/2014 06:32 AM, Christian Engelmayer wrote: > Fix a memory leak in the lp3943_pwm_request_map() error handling path. > Make sure already allocated pwm map memory is freed correctly. > Detected by Coverity: CID 1162829. > > Signed-off-by: Christian Engelmayer <cengelma@gmx.at> Acked-by: Milo Kim <milo.kim@ti.com> Thanks! Milo ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pwm: lp3943: Fix potential memory leak during request 2014-01-23 21:32 [PATCH] pwm: lp3943: Fix potential memory leak during request Christian Engelmayer 2014-01-23 22:47 ` Milo Kim @ 2014-01-24 16:23 ` Thierry Reding 2014-01-27 9:58 ` Lee Jones 2014-02-26 15:09 ` Thierry Reding 2 siblings, 1 reply; 6+ messages in thread From: Thierry Reding @ 2014-01-24 16:23 UTC (permalink / raw) To: Lee Jones; +Cc: Christian Engelmayer, Milo Kim, linux-pwm [-- Attachment #1: Type: text/plain, Size: 1313 bytes --] On Thu, Jan 23, 2014 at 10:32:20PM +0100, Christian Engelmayer wrote: > Fix a memory leak in the lp3943_pwm_request_map() error handling path. > Make sure already allocated pwm map memory is freed correctly. > Detected by Coverity: CID 1162829. > > Signed-off-by: Christian Engelmayer <cengelma@gmx.at> > --- > drivers/pwm/pwm-lp3943.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c > index 8a843a0..a40b9c3 100644 > --- a/drivers/pwm/pwm-lp3943.c > +++ b/drivers/pwm/pwm-lp3943.c > @@ -52,8 +52,10 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm) > offset = pwm_map->output[i]; > > /* Return an error if the pin is already assigned */ > - if (test_and_set_bit(offset, &lp3943->pin_used)) > + if (test_and_set_bit(offset, &lp3943->pin_used)) { > + kfree(pwm_map); > return ERR_PTR(-EBUSY); > + } > } > > return pwm_map; > -- > 1.8.3.2 Lee, since you took this driver via the MFD tree, would you mind picking up this fix as well? In case you don't have it in your inbox somewhere, you should be able to grab it from here: http://patchwork.ozlabs.org/patch/313741/ In that case: Acked-by: Thierry Reding <thierry.reding@gmail.com> Thierry [-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pwm: lp3943: Fix potential memory leak during request 2014-01-24 16:23 ` Thierry Reding @ 2014-01-27 9:58 ` Lee Jones 2014-01-27 12:51 ` Thierry Reding 0 siblings, 1 reply; 6+ messages in thread From: Lee Jones @ 2014-01-27 9:58 UTC (permalink / raw) To: Thierry Reding; +Cc: Christian Engelmayer, Milo Kim, linux-pwm On Fri, 24 Jan 2014, Thierry Reding wrote: > On Thu, Jan 23, 2014 at 10:32:20PM +0100, Christian Engelmayer wrote: > > Fix a memory leak in the lp3943_pwm_request_map() error handling path. > > Make sure already allocated pwm map memory is freed correctly. > > Detected by Coverity: CID 1162829. > > > > Signed-off-by: Christian Engelmayer <cengelma@gmx.at> > > --- > > drivers/pwm/pwm-lp3943.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c > > index 8a843a0..a40b9c3 100644 > > --- a/drivers/pwm/pwm-lp3943.c > > +++ b/drivers/pwm/pwm-lp3943.c > > @@ -52,8 +52,10 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm) > > offset = pwm_map->output[i]; > > > > /* Return an error if the pin is already assigned */ > > - if (test_and_set_bit(offset, &lp3943->pin_used)) > > + if (test_and_set_bit(offset, &lp3943->pin_used)) { > > + kfree(pwm_map); > > return ERR_PTR(-EBUSY); > > + } > > } > > > > return pwm_map; > > Lee, since you took this driver via the MFD tree, would you mind picking > up this fix as well? Everything I have is now in Mainline. It's best for you to apply it now I think? > In case you don't have it in your inbox somewhere, you should be able to > grab it from here: > > http://patchwork.ozlabs.org/patch/313741/ > > In that case: > > Acked-by: Thierry Reding <thierry.reding@gmail.com> > > Thierry -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pwm: lp3943: Fix potential memory leak during request 2014-01-27 9:58 ` Lee Jones @ 2014-01-27 12:51 ` Thierry Reding 0 siblings, 0 replies; 6+ messages in thread From: Thierry Reding @ 2014-01-27 12:51 UTC (permalink / raw) To: Lee Jones; +Cc: Christian Engelmayer, Milo Kim, linux-pwm [-- Attachment #1: Type: text/plain, Size: 1711 bytes --] On Mon, Jan 27, 2014 at 09:58:03AM +0000, Lee Jones wrote: > On Fri, 24 Jan 2014, Thierry Reding wrote: > > > On Thu, Jan 23, 2014 at 10:32:20PM +0100, Christian Engelmayer wrote: > > > Fix a memory leak in the lp3943_pwm_request_map() error handling path. > > > Make sure already allocated pwm map memory is freed correctly. > > > Detected by Coverity: CID 1162829. > > > > > > Signed-off-by: Christian Engelmayer <cengelma@gmx.at> > > > --- > > > drivers/pwm/pwm-lp3943.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c > > > index 8a843a0..a40b9c3 100644 > > > --- a/drivers/pwm/pwm-lp3943.c > > > +++ b/drivers/pwm/pwm-lp3943.c > > > @@ -52,8 +52,10 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm) > > > offset = pwm_map->output[i]; > > > > > > /* Return an error if the pin is already assigned */ > > > - if (test_and_set_bit(offset, &lp3943->pin_used)) > > > + if (test_and_set_bit(offset, &lp3943->pin_used)) { > > > + kfree(pwm_map); > > > return ERR_PTR(-EBUSY); > > > + } > > > } > > > > > > return pwm_map; > > > > Lee, since you took this driver via the MFD tree, would you mind picking > > up this fix as well? > > Everything I have is now in Mainline. > > It's best for you to apply it now I think? Sure, I could do that after -rc1 is released. It's somewhat problematic because I can't really create a tree that's based on yours before -rc1. After -rc1 it shouldn't be a problem and this also isn't all that critical, so sending off another pull request to Linus after -rc1 is probably what I'll do. Thierry [-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pwm: lp3943: Fix potential memory leak during request 2014-01-23 21:32 [PATCH] pwm: lp3943: Fix potential memory leak during request Christian Engelmayer 2014-01-23 22:47 ` Milo Kim 2014-01-24 16:23 ` Thierry Reding @ 2014-02-26 15:09 ` Thierry Reding 2 siblings, 0 replies; 6+ messages in thread From: Thierry Reding @ 2014-02-26 15:09 UTC (permalink / raw) To: Christian Engelmayer; +Cc: Milo Kim, linux-pwm [-- Attachment #1: Type: text/plain, Size: 500 bytes --] On Thu, Jan 23, 2014 at 10:32:20PM +0100, Christian Engelmayer wrote: > Fix a memory leak in the lp3943_pwm_request_map() error handling path. > Make sure already allocated pwm map memory is freed correctly. > Detected by Coverity: CID 1162829. > > Signed-off-by: Christian Engelmayer <cengelma@gmx.at> > --- > drivers/pwm/pwm-lp3943.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) I've applied this and sent it off to Linus for inclusion in v3.14-rc5. Thanks, Thierry [-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-26 15:09 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-01-23 21:32 [PATCH] pwm: lp3943: Fix potential memory leak during request Christian Engelmayer 2014-01-23 22:47 ` Milo Kim 2014-01-24 16:23 ` Thierry Reding 2014-01-27 9:58 ` Lee Jones 2014-01-27 12:51 ` Thierry Reding 2014-02-26 15:09 ` Thierry Reding
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.