]> git.baikalelectronics.ru Git - kernel.git/commit
net: sfp: fix memory leak in sfp_probe()
authorJianglei Nie <niejianglei2021@163.com>
Wed, 29 Jun 2022 07:55:50 +0000 (15:55 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 30 Jun 2022 09:38:16 +0000 (11:38 +0200)
commit1257e3f81cd8cb05a0cc25beb4f4a28379c9003b
treef8d20ec84e2c949d8acff299481717ab216c062a
parent024cc509eae4d26049ba2af38f0c293f3c1f724d
net: sfp: fix memory leak in sfp_probe()

sfp_probe() allocates a memory chunk from sfp with sfp_alloc(). When
devm_add_action() fails, sfp is not freed, which leads to a memory leak.

We should use devm_add_action_or_reset() instead of devm_add_action().

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/20220629075550.2152003-1-niejianglei2021@163.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/phy/sfp.c