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 <[email protected]>
---
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
> 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
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
> .
>
>>> 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
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
> .
>