]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
octeon_ep: Fix memory leak in octep_device_setup()
authorZilin Guan <zilin@seu.edu.cn>
Wed, 21 Jan 2026 13:05:51 +0000 (13:05 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 23 Jan 2026 19:45:36 +0000 (11:45 -0800)
In octep_device_setup(), if octep_ctrl_net_init() fails, the function
returns directly without unmapping the mapped resources and freeing the
allocated configuration memory.

Fix this by jumping to the unsupported_dev label, which performs the
necessary cleanup. This aligns with the error handling logic of other
paths in this function.

Compile tested only. Issue found using a prototype static analysis tool
and code review.

Fixes: 577f0d1b1c5f ("octeon_ep: add separate mailbox command and response queues")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20260121130551.3717090-1-zilin@seu.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeon_ep/octep_main.c

index bcea3fc26a8c7d64418eae18e2dc787224e6938d..57db7ea2f5be9c01b8501ad7d3f3f3adfc9d4f03 100644 (file)
@@ -1338,7 +1338,7 @@ int octep_device_setup(struct octep_device *oct)
 
        ret = octep_ctrl_net_init(oct);
        if (ret)
-               return ret;
+               goto unsupported_dev;
 
        INIT_WORK(&oct->tx_timeout_task, octep_tx_timeout_task);
        INIT_WORK(&oct->ctrl_mbox_task, octep_ctrl_mbox_task);