* [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
@ 2023-04-18 9:07 Li Yang
2023-04-18 9:17 ` 李阳
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Li Yang @ 2023-04-18 9:07 UTC (permalink / raw)
To: Greg Kroah-Hartman, Felipe Balbi, Sergey Shtylyov
Cc: Li Yang, Dongliang Mu, linux-usb, linux-kernel
Smatch reports:
drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
warn: missing unwind goto?
After geting irq, if ret < 0, it will return without error handling to
free memory.
Just add error handling to fix this problem.
Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check")
Signed-off-by: Li Yang <lidaxian@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
The issue is found by static analysis, and the patch remains untest.
---
drivers/usb/phy/phy-tahvo.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index f2d2cc586c5b..184a5f3d7473 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -390,8 +390,11 @@ static int tahvo_usb_probe(struct platform_device *pdev)
dev_set_drvdata(&pdev->dev, tu);
tu->irq = ret = platform_get_irq(pdev, 0);
- if (ret < 0)
- return ret;
+ if (ret < 0) {
+ dev_err(&pdev->dev, "could not get irq: %d\n",
+ ret);
+ goto err_remove_phy;
+ }
ret = request_threaded_irq(tu->irq, NULL, tahvo_usb_vbus_interrupt,
IRQF_ONESHOT,
"tahvo-vbus", tu);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
2023-04-18 9:07 [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe() Li Yang
@ 2023-04-18 9:17 ` 李阳
2023-04-18 9:19 ` Greg Kroah-Hartman
2023-04-18 11:17 ` Sergey Shtylyov
2 siblings, 0 replies; 6+ messages in thread
From: 李阳 @ 2023-04-18 9:17 UTC (permalink / raw)
To: greg kroah-hartman, felipe balbi, sergey shtylyov
Cc: dongliang mu, linux-usb, linux-kernel, hust-os-kernel-patches
> -----Original Messages-----
> From: "Li Yang" <lidaxian@hust.edu.cn>
> Sent Time: 2023-04-18 17:07:57 (Tuesday)
> To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, "Felipe Balbi" <balbi@kernel.org>, "Sergey Shtylyov" <s.shtylyov@omp.ru>
> Cc: "Li Yang" <lidaxian@hust.edu.cn>, "Dongliang Mu" <dzm91@hust.edu.cn>, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
>
> Smatch reports:
> drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
> warn: missing unwind goto?
>
> After geting irq, if ret < 0, it will return without error handling to
> free memory.
> Just add error handling to fix this problem.
>
> Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check")
> Signed-off-by: Li Yang <lidaxian@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> The issue is found by static analysis, and the patch remains untest.
> ---
> drivers/usb/phy/phy-tahvo.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
> index f2d2cc586c5b..184a5f3d7473 100644
> --- a/drivers/usb/phy/phy-tahvo.c
> +++ b/drivers/usb/phy/phy-tahvo.c
> @@ -390,8 +390,11 @@ static int tahvo_usb_probe(struct platform_device *pdev)
> dev_set_drvdata(&pdev->dev, tu);
>
> tu->irq = ret = platform_get_irq(pdev, 0);
> - if (ret < 0)
> - return ret;
> + if (ret < 0) {
> + dev_err(&pdev->dev, "could not get irq: %d\n",
> + ret);
> + goto err_remove_phy;
> + }
> ret = request_threaded_irq(tu->irq, NULL, tahvo_usb_vbus_interrupt,
> IRQF_ONESHOT,
> "tahvo-vbus", tu);
> --
> 2.34.1
cc hust-os-kernel-patches@googlegroups.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
2023-04-18 9:07 [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe() Li Yang
2023-04-18 9:17 ` 李阳
@ 2023-04-18 9:19 ` Greg Kroah-Hartman
2023-04-18 10:48 ` 李阳
2023-04-18 11:17 ` Sergey Shtylyov
2 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2023-04-18 9:19 UTC (permalink / raw)
To: Li Yang
Cc: Felipe Balbi, Sergey Shtylyov, Dongliang Mu, linux-usb, linux-kernel
On Tue, Apr 18, 2023 at 05:07:57PM +0800, Li Yang wrote:
> Smatch reports:
> drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
> warn: missing unwind goto?
>
> After geting irq, if ret < 0, it will return without error handling to
> free memory.
> Just add error handling to fix this problem.
>
> Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check")
> Signed-off-by: Li Yang <lidaxian@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> The issue is found by static analysis, and the patch remains untest.
> ---
> drivers/usb/phy/phy-tahvo.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
> index f2d2cc586c5b..184a5f3d7473 100644
> --- a/drivers/usb/phy/phy-tahvo.c
> +++ b/drivers/usb/phy/phy-tahvo.c
> @@ -390,8 +390,11 @@ static int tahvo_usb_probe(struct platform_device *pdev)
> dev_set_drvdata(&pdev->dev, tu);
>
> tu->irq = ret = platform_get_irq(pdev, 0);
> - if (ret < 0)
> - return ret;
> + if (ret < 0) {
> + dev_err(&pdev->dev, "could not get irq: %d\n",
> + ret);
Why print this out? And why the odd line-wrapping?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Re: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
2023-04-18 9:19 ` Greg Kroah-Hartman
@ 2023-04-18 10:48 ` 李阳
0 siblings, 0 replies; 6+ messages in thread
From: 李阳 @ 2023-04-18 10:48 UTC (permalink / raw)
To: greg kroah-hartman
Cc: felipe balbi, sergey shtylyov, dongliang mu, linux-usb,
linux-kernel, hust-os-kernel-patches
> -----Original Messages-----
> From: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
> Sent Time: 2023-04-18 17:19:12 (Tuesday)
> To: "Li Yang" <lidaxian@hust.edu.cn>
> Cc: "Felipe Balbi" <balbi@kernel.org>, "Sergey Shtylyov" <s.shtylyov@omp.ru>, "Dongliang Mu" <dzm91@hust.edu.cn>, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
>
> On Tue, Apr 18, 2023 at 05:07:57PM +0800, Li Yang wrote:
> > Smatch reports:
> > drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
> > warn: missing unwind goto?
> >
> > After geting irq, if ret < 0, it will return without error handling to
> > free memory.
> > Just add error handling to fix this problem.
> >
> > Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check")
> > Signed-off-by: Li Yang <lidaxian@hust.edu.cn>
> > Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> > ---
> > The issue is found by static analysis, and the patch remains untest.
> > ---
> > drivers/usb/phy/phy-tahvo.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
> > index f2d2cc586c5b..184a5f3d7473 100644
> > --- a/drivers/usb/phy/phy-tahvo.c
> > +++ b/drivers/usb/phy/phy-tahvo.c
> > @@ -390,8 +390,11 @@ static int tahvo_usb_probe(struct platform_device *pdev)
> > dev_set_drvdata(&pdev->dev, tu);
> >
> > tu->irq = ret = platform_get_irq(pdev, 0);
> > - if (ret < 0)
> > - return ret;
> > + if (ret < 0) {
> > + dev_err(&pdev->dev, "could not get irq: %d\n",
> > + ret);
>
> Why print this out? And why the odd line-wrapping?
>
> thanks,
>
> greg k-h
For the first question, I am just emulating the coding style of the original author who outputs corresponding information after each error. If there is anything unreasonable about doing so, please let me know. As for the second question, it's my mistake and I will correct it immediately.
regrads,
Li Yang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
2023-04-18 9:07 [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe() Li Yang
2023-04-18 9:17 ` 李阳
2023-04-18 9:19 ` Greg Kroah-Hartman
@ 2023-04-18 11:17 ` Sergey Shtylyov
2023-04-19 9:00 ` Sergey Shtylyov
2 siblings, 1 reply; 6+ messages in thread
From: Sergey Shtylyov @ 2023-04-18 11:17 UTC (permalink / raw)
To: Li Yang, Greg Kroah-Hartman, Felipe Balbi
Cc: Dongliang Mu, linux-usb, linux-kernel
Hello!
On 4/18/23 12:07 PM, Li Yang wrote:
> Smatch reports:
> drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
> warn: missing unwind goto?
>
> After geting irq, if ret < 0, it will return without error handling to
> free memory.
> Just add error handling to fix this problem.
Oops, I'm sorry for missing that one...
> Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check")
> Signed-off-by: Li Yang <lidaxian@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> The issue is found by static analysis, and the patch remains untest.
> ---
> drivers/usb/phy/phy-tahvo.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
> index f2d2cc586c5b..184a5f3d7473 100644
> --- a/drivers/usb/phy/phy-tahvo.c
> +++ b/drivers/usb/phy/phy-tahvo.c
> @@ -390,8 +390,11 @@ static int tahvo_usb_probe(struct platform_device *pdev)
> dev_set_drvdata(&pdev->dev, tu);
>
> tu->irq = ret = platform_get_irq(pdev, 0);
> - if (ret < 0)
> - return ret;
> + if (ret < 0) {
> + dev_err(&pdev->dev, "could not get irq: %d\n",
> + ret);
Adding the error message needs another patch, strictly speaking...
> + goto err_remove_phy;
> + }
> ret = request_threaded_irq(tu->irq, NULL, tahvo_usb_vbus_interrupt,
> IRQF_ONESHOT,
> "tahvo-vbus", tu);
MBR, Sergey
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
2023-04-18 11:17 ` Sergey Shtylyov
@ 2023-04-19 9:00 ` Sergey Shtylyov
0 siblings, 0 replies; 6+ messages in thread
From: Sergey Shtylyov @ 2023-04-19 9:00 UTC (permalink / raw)
To: Li Yang, Greg Kroah-Hartman, Felipe Balbi
Cc: Dongliang Mu, linux-usb, linux-kernel
On 4/18/23 2:17 PM, Sergey Shtylyov wrote:
[...]
>> Smatch reports:
>> drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
>> warn: missing unwind goto?
>>
>> After geting irq, if ret < 0, it will return without error handling to
>> free memory.
>> Just add error handling to fix this problem.
>
> Oops, I'm sorry for missing that one...
>
>> Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check")
>> Signed-off-by: Li Yang <lidaxian@hust.edu.cn>
>> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
>> ---
>> The issue is found by static analysis, and the patch remains untest.
>> ---
>> drivers/usb/phy/phy-tahvo.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
>> index f2d2cc586c5b..184a5f3d7473 100644
>> --- a/drivers/usb/phy/phy-tahvo.c
>> +++ b/drivers/usb/phy/phy-tahvo.c
>> @@ -390,8 +390,11 @@ static int tahvo_usb_probe(struct platform_device *pdev)
>> dev_set_drvdata(&pdev->dev, tu);
>>
>> tu->irq = ret = platform_get_irq(pdev, 0);
>> - if (ret < 0)
>> - return ret;
>> + if (ret < 0) {
>> + dev_err(&pdev->dev, "could not get irq: %d\n",
>> + ret);
>
> Adding the error message needs another patch, strictly speaking...
And if you look at platform_get_irq(), you'll see that it prints an error msg
itself...
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-19 9:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 9:07 [PATCH] usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe() Li Yang
2023-04-18 9:17 ` 李阳
2023-04-18 9:19 ` Greg Kroah-Hartman
2023-04-18 10:48 ` 李阳
2023-04-18 11:17 ` Sergey Shtylyov
2023-04-19 9:00 ` Sergey Shtylyov
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.