diff mbox series

[net] net: ethernet: wiznet: w5300: free irq when alloc link_name failed in w5300_hw_probe()

Message ID 20221119071007.3858043-1-cuigaosheng1@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] net: ethernet: wiznet: w5300: free irq when alloc link_name failed in w5300_hw_probe() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: leon@kernel.org mw@semihalf.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Gaosheng Cui Nov. 19, 2022, 7:10 a.m. UTC
When alloc link_name failed in w5300_hw_probe(), irq has not been
freed. Fix it.

Fixes: 9899b81e7ca5 ("Ethernet driver for the WIZnet W5300 chip")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 drivers/net/ethernet/wiznet/w5300.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky Nov. 22, 2022, 12:28 p.m. UTC | #1
On Sat, Nov 19, 2022 at 03:10:07PM +0800, Gaosheng Cui wrote:
> When alloc link_name failed in w5300_hw_probe(), irq has not been
> freed. Fix it.
> 
> Fixes: 9899b81e7ca5 ("Ethernet driver for the WIZnet W5300 chip")
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
>  drivers/net/ethernet/wiznet/w5300.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/wiznet/w5300.c b/drivers/net/ethernet/wiznet/w5300.c
> index b0958fe8111e..5571d4c365e9 100644
> --- a/drivers/net/ethernet/wiznet/w5300.c
> +++ b/drivers/net/ethernet/wiznet/w5300.c
> @@ -572,8 +572,10 @@ static int w5300_hw_probe(struct platform_device *pdev)
>  	priv->link_gpio = data ? data->link_gpio : -EINVAL;
>  	if (gpio_is_valid(priv->link_gpio)) {
>  		char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL);
> -		if (!link_name)
> +		if (!link_name) {
> +			free_irq(irq, ndev);
>  			return -ENOMEM;
> +		}
>  		snprintf(link_name, 16, "%s-link", name);
>  		priv->link_irq = gpio_to_irq(priv->link_gpio);
>  		if (request_any_context_irq(priv->link_irq, w5300_detect_link,

  579                 if (request_any_context_irq(priv->link_irq, w5300_detect_link,
  580                                 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  581                                 link_name, priv->ndev) < 0)
  582                         priv->link_gpio = -EINVAL;

You should call to same free_irq(irq, ndev) in this "if" too.

Thanks

> -- 
> 2.25.1
>
Gaosheng Cui Nov. 22, 2022, 1:05 p.m. UTC | #2
>    579                 if (request_any_context_irq(priv->link_irq, w5300_detect_link,
>    580                                 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
>    581                                 link_name, priv->ndev) < 0)
>    582                         priv->link_gpio = -EINVAL;
>
> You should call to same free_irq(irq, ndev) in this "if" too.
>
> Thanks

Thanks for taking time to review this patch, if request_any_context_irq(...) failed,
w5300_hw_probe will return 0(success), should I call the free_irq(...) in this case?

Thanks.

On 2022/11/22 20:28, Leon Romanovsky wrote:
> On Sat, Nov 19, 2022 at 03:10:07PM +0800, Gaosheng Cui wrote:
>> When alloc link_name failed in w5300_hw_probe(), irq has not been
>> freed. Fix it.
>>
>> Fixes: 9899b81e7ca5 ("Ethernet driver for the WIZnet W5300 chip")
>> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
>> ---
>>   drivers/net/ethernet/wiznet/w5300.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/wiznet/w5300.c b/drivers/net/ethernet/wiznet/w5300.c
>> index b0958fe8111e..5571d4c365e9 100644
>> --- a/drivers/net/ethernet/wiznet/w5300.c
>> +++ b/drivers/net/ethernet/wiznet/w5300.c
>> @@ -572,8 +572,10 @@ static int w5300_hw_probe(struct platform_device *pdev)
>>   	priv->link_gpio = data ? data->link_gpio : -EINVAL;
>>   	if (gpio_is_valid(priv->link_gpio)) {
>>   		char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL);
>> -		if (!link_name)
>> +		if (!link_name) {
>> +			free_irq(irq, ndev);
>>   			return -ENOMEM;
>> +		}
>>   		snprintf(link_name, 16, "%s-link", name);
>>   		priv->link_irq = gpio_to_irq(priv->link_gpio);
>>   		if (request_any_context_irq(priv->link_irq, w5300_detect_link,
>    579                 if (request_any_context_irq(priv->link_irq, w5300_detect_link,
>    580                                 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
>    581                                 link_name, priv->ndev) < 0)
>    582                         priv->link_gpio = -EINVAL;
>
> You should call to same free_irq(irq, ndev) in this "if" too.
>
> Thanks
>
>> -- 
>> 2.25.1
>>
> .
diff mbox series

Patch

diff --git a/drivers/net/ethernet/wiznet/w5300.c b/drivers/net/ethernet/wiznet/w5300.c
index b0958fe8111e..5571d4c365e9 100644
--- a/drivers/net/ethernet/wiznet/w5300.c
+++ b/drivers/net/ethernet/wiznet/w5300.c
@@ -572,8 +572,10 @@  static int w5300_hw_probe(struct platform_device *pdev)
 	priv->link_gpio = data ? data->link_gpio : -EINVAL;
 	if (gpio_is_valid(priv->link_gpio)) {
 		char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL);
-		if (!link_name)
+		if (!link_name) {
+			free_irq(irq, ndev);
 			return -ENOMEM;
+		}
 		snprintf(link_name, 16, "%s-link", name);
 		priv->link_irq = gpio_to_irq(priv->link_gpio);
 		if (request_any_context_irq(priv->link_irq, w5300_detect_link,