[PW_SID:1081700] soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration#1776
[PW_SID:1081700] soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration#1776linux-riscv-bot wants to merge 1 commit into
Conversation
…ice registration
When platform_device_register() fails in mpfs_sys_controller_probe(),
the embedded struct device in subdevs[i] has already been initialized by
device_initialize(), but the failure path only reports the error and
does not drop the device reference for the current platform device:
mpfs_sys_controller_probe()
-> platform_device_register(&subdevs[i])
-> device_initialize(&subdevs[i].dev)
-> setup_pdev_dma_masks(&subdevs[i])
-> platform_device_add(&subdevs[i])
This leads to a reference leak when platform_device_register() fails.
Fix this by calling platform_device_put() after reporting the error.
The issue was identified by a static analysis tool I developed and
confirmed by manual review.
Fixes: d0054a4 ("soc: add microchip polarfire soc system controller")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
|
Patch 1: "soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration" |
PR for series 1081700 applied to workflow__riscv__fixes
Name: soc: microchip: mpfs-sys-controller: fix reference leak on failed device registration
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1081700
Version: 1