linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] scsi: fcoe: add missed kfree() in an error path
@ 2020-07-07 11:38 Markus Elfring
  2020-07-09  2:11 ` Jing Xiangfeng
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2020-07-07 11:38 UTC (permalink / raw)
  To: Jing Xiangfeng, linux-scsi
  Cc: kernel-janitors, linux-kernel, Hannes Reinecke,
	James E. J. Bottomley, Martin K. Petersen, Neerav Parikh,
	Robert Love

> fcoe_fdmi_info() misses to call kfree() in an error path.
> Add the missed function call to fix it.

I suggest to use an additional jump target for the completion
of the desired exception handling.


…
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -830,6 +830,7 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
>  		if (rc) {
>  			printk(KERN_INFO "fcoe: Failed to retrieve FDMI "
>  					"information from netdev.\n");
> +			kfree(fdmi);
>  			return;
>  		}

-			return;
+			goto free_fdmi;


How do you think about to apply any further coding style adjustments?

Regards,
Markus

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

* Re: [PATCH] scsi: fcoe: add missed kfree() in an error path
  2020-07-07 11:38 [PATCH] scsi: fcoe: add missed kfree() in an error path Markus Elfring
@ 2020-07-09  2:11 ` Jing Xiangfeng
  2020-07-09  7:22   ` Markus Elfring
  0 siblings, 1 reply; 5+ messages in thread
From: Jing Xiangfeng @ 2020-07-09  2:11 UTC (permalink / raw)
  To: Markus Elfring, linux-scsi
  Cc: kernel-janitors, linux-kernel, Hannes Reinecke,
	James E. J. Bottomley, Martin K. Petersen, Neerav Parikh,
	Robert Love



On 2020/7/7 19:38, Markus Elfring wrote:
>> fcoe_fdmi_info() misses to call kfree() in an error path.
>> Add the missed function call to fix it.
>
> I suggest to use an additional jump target for the completion
> of the desired exception handling.
>
>
> …
>> +++ b/drivers/scsi/fcoe/fcoe.c
>> @@ -830,6 +830,7 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
>>   		if (rc) {
>>   			printk(KERN_INFO "fcoe: Failed to retrieve FDMI "
>>   					"information from netdev.\n");
>> +			kfree(fdmi);
>>   			return;
>>   		}
>
> -			return;
> +			goto free_fdmi;
>
>
> How do you think about to apply any further coding style adjustments?

The local variable "fdmi" is invisible to the function.
See fcoe_fdmi_info().

	Thanks
>
> Regards,
> Markus
> .
>

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

* Re: [PATCH] scsi: fcoe: add missed kfree() in an error path
  2020-07-09  2:11 ` Jing Xiangfeng
@ 2020-07-09  7:22   ` Markus Elfring
  2020-07-09 11:08     ` Jing Xiangfeng
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2020-07-09  7:22 UTC (permalink / raw)
  To: Jing Xiangfeng, linux-scsi
  Cc: kernel-janitors, linux-kernel, Hannes Reinecke,
	James E. J. Bottomley, Martin K. Petersen, Neerav Parikh

>>> fcoe_fdmi_info() misses to call kfree() in an error path.
>>> Add the missed function call to fix it.
>>
>> I suggest to use an additional jump target for the completion
>> of the desired exception handling.
>>
>>
>> …
>>> +++ b/drivers/scsi/fcoe/fcoe.c
>>> @@ -830,6 +830,7 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
>>>           if (rc) {
>>>               printk(KERN_INFO "fcoe: Failed to retrieve FDMI "
>>>                       "information from netdev.\n");
>>> +            kfree(fdmi);
>>>               return;
>>>           }
>>
>> -            return;
>> +            goto free_fdmi;
>>
>>
>> How do you think about to apply any further coding style adjustments?
>
> The local variable "fdmi" is invisible to the function.

I have got understanding difficulties for this information.
The function call “kfree(fdmi)” is already used at the end of this if branch.
Thus I propose to add a label there.

Do you notice any additional improvement possibilities for this software module?

Regards,
Markus

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

* Re: [PATCH] scsi: fcoe: add missed kfree() in an error path
  2020-07-09  7:22   ` Markus Elfring
@ 2020-07-09 11:08     ` Jing Xiangfeng
  0 siblings, 0 replies; 5+ messages in thread
From: Jing Xiangfeng @ 2020-07-09 11:08 UTC (permalink / raw)
  To: Markus Elfring, linux-scsi
  Cc: kernel-janitors, linux-kernel, Hannes Reinecke,
	James E. J. Bottomley, Martin K. Petersen, Neerav Parikh



On 2020/7/9 15:22, Markus Elfring wrote:
>>>> fcoe_fdmi_info() misses to call kfree() in an error path.
>>>> Add the missed function call to fix it.
>>>
>>> I suggest to use an additional jump target for the completion
>>> of the desired exception handling.
>>>
>>>
>>> …
>>>> +++ b/drivers/scsi/fcoe/fcoe.c
>>>> @@ -830,6 +830,7 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
>>>>            if (rc) {
>>>>                printk(KERN_INFO "fcoe: Failed to retrieve FDMI "
>>>>                        "information from netdev.\n");
>>>> +            kfree(fdmi);
>>>>                return;
>>>>            }
>>>
>>> -            return;
>>> +            goto free_fdmi;
>>>
>>>
>>> How do you think about to apply any further coding style adjustments?
>>
>> The local variable "fdmi" is invisible to the function.
>
> I have got understanding difficulties for this information.
> The function call “kfree(fdmi)” is already used at the end of this if branch.
> Thus I propose to add a label there.
>
> Do you notice any additional improvement possibilities for this software module?

Indeed, Will change in the next version.
Thanks for your review
>
> Regards,
> Markus
> .
>

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

* [PATCH] scsi: fcoe: add missed kfree() in an error path
@ 2020-07-07 10:24 Jing Xiangfeng
  0 siblings, 0 replies; 5+ messages in thread
From: Jing Xiangfeng @ 2020-07-07 10:24 UTC (permalink / raw)
  To: hare, jejb, martin.petersen, robert.w.love, Neerav.Parikh
  Cc: linux-scsi, linux-kernel, jingxiangfeng

fcoe_fdmi_info() misses to call kfree() in an error path.
Add the missed function call to fix it.

Fixes: f07d46bbc9ba ("fcoe: Fix smatch warning in fcoe_fdmi_info function")
Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
---
 drivers/scsi/fcoe/fcoe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 25dae9f0b205..976f70cbe043 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -830,6 +830,7 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev)
 		if (rc) {
 			printk(KERN_INFO "fcoe: Failed to retrieve FDMI "
 					"information from netdev.\n");
+			kfree(fdmi);
 			return;
 		}
 
-- 
2.17.1


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

end of thread, other threads:[~2020-07-09 11:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 11:38 [PATCH] scsi: fcoe: add missed kfree() in an error path Markus Elfring
2020-07-09  2:11 ` Jing Xiangfeng
2020-07-09  7:22   ` Markus Elfring
2020-07-09 11:08     ` Jing Xiangfeng
  -- strict thread matches above, loose matches on Subject: below --
2020-07-07 10:24 Jing Xiangfeng

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).