fjes: fix memleaks in fjes_hw_setup
authorZhipeng Lu <alexious@zju.edu.cn>
Mon, 22 Jan 2024 17:24:42 +0000 (01:24 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Jan 2024 02:03:53 +0000 (18:03 -0800)
commitf6cc4b6a3ae53df425771000e9c9540cce9b7bb1
treee26e8e07ee5c5e37ac6fd21a36f6aa495db0253d
parent77be22473b28f0538d69d58f64d35091095688cd
fjes: fix memleaks in fjes_hw_setup

In fjes_hw_setup, it allocates several memory and delay the deallocation
to the fjes_hw_exit in fjes_probe through the following call chain:

fjes_probe
  |-> fjes_hw_init
        |-> fjes_hw_setup
  |-> fjes_hw_exit

However, when fjes_hw_setup fails, fjes_hw_exit won't be called and thus
all the resources allocated in fjes_hw_setup will be leaked. In this
patch, we free those resources in fjes_hw_setup and prevents such leaks.

Fixes: 2fcbca687702 ("fjes: platform_driver's .probe and .remove routine")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240122172445.3841883-1-alexious@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/fjes/fjes_hw.c