Re: [PATCH] scsi: fcoe: add missed kfree() in an error path

From: Markus Elfring
Date: Thu Jul 09 2020 - 03:23:04 EST


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