Page MenuHomeFreeBSD

Don't leak `work` if `__mlx4_register_vlan` fails in `mlx4_master_immediate_activate_vlan_qos`
ClosedPublic

Authored by ngie on Nov 19 2015, 12:49 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 5 2024, 4:22 PM
Unknown Object (File)
Jan 5 2024, 4:22 PM
Unknown Object (File)
Jan 5 2024, 4:10 PM
Unknown Object (File)
Dec 21 2023, 10:50 PM
Unknown Object (File)
Dec 20 2023, 12:15 AM
Unknown Object (File)
Dec 16 2023, 8:57 AM
Unknown Object (File)
Dec 16 2023, 8:57 AM
Unknown Object (File)
Sep 6 2023, 5:54 AM
Subscribers

Details

Summary

Don't leak work if __mlx4_register_vlan fails in mlx4_master_immediate_activate_vlan_qos

MFC after: 3 days
Submitted by: Miles Olrich <miles.olrich@isilon.com>
Sponsored by: EMC / Isilon Storage Division

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 1206
Build 1210: arc lint + arc unit

Event Timeline

ngie retitled this revision from to Don't leak `work` if `__mlx4_register_vlan` fails in `mlx4_master_immediate_activate_vlan_qos`.
ngie updated this object.
ngie added reviewers: hselasky, markj.
ngie added a subscriber: benno.

Looks correct to me, but I'd suggest using an err goto label instead - that's how pretty much all the error-handling is done in the OFED code.

In D4203#88493, @markj wrote:

Looks correct to me, but I'd suggest using an err goto label instead - that's how pretty much all the error-handling is done in the OFED code.

work is usable in the positive case though.

A few other spots in the code do the same thing (just return instead of goto'ing to a label):

 932                                 if (!err) {
 933                                         for (vidx = index * 32; vidx < (index + 1) * 32; ++vidx) {
 934                                                 pidx = priv->virt2phys_pkey[slave][port - 1][vidx];
 935                                                 outtab[vidx % 32] = cpu_to_be16(table[pidx]);
 936                                         }
 937                                 }
 938                                 kfree(table);
 939                                 return err;
 940                         }
 ...
1614                 if (ret) {
1615                         mlx4_err(dev, "%s:Failed reading vhcr"
1616                                  "ret: 0x%x\n", __func__, ret);
1617                         kfree(vhcr);
1618                         return ret;
1619                 }
 ...
2405         if (!mailbox->buf) {
2406                 kfree(mailbox);
2407                 return ERR_PTR(-ENOMEM);
2408         }
markj edited edge metadata.

I'm suggesting having:

return 0;

err:

kfree(work);
return err;

There are counterexamples, but this is the most common and best pattern. But it's not a big deal in this case.

This revision is now accepted and ready to land.Nov 19 2015, 1:07 AM