Commit f1f21bec authored by Tejas Patel's avatar Tejas Patel Committed by Michal Simek

firmware: xilinx: Fix dereferencing freed memory

Fix smatch warning:
drivers/firmware/xilinx/zynqmp.c:1288 zynqmp_firmware_remove()
error: dereferencing freed memory 'feature_data'

Use hash_for_each_safe for safe removal of hash entry.

Fixes: acfdd185 ("firmware: xilinx: Use hash-table for api feature check")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarTejas Patel <tejas.patel@xilinx.com>
Signed-off-by: default avatarRajan Vaja <rajan.vaja@xilinx.com>
Link: https://lore.kernel.org/r/1612765883-22018-1-git-send-email-rajan.vaja@xilinx.comSigned-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
parent fe07bfda
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
* Xilinx Zynq MPSoC Firmware layer * Xilinx Zynq MPSoC Firmware layer
* *
* Copyright (C) 2014-2020 Xilinx, Inc. * Copyright (C) 2014-2021 Xilinx, Inc.
* *
* Michal Simek <michal.simek@xilinx.com> * Michal Simek <michal.simek@xilinx.com>
* Davorin Mista <davorin.mista@aggios.com> * Davorin Mista <davorin.mista@aggios.com>
...@@ -1280,12 +1280,13 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) ...@@ -1280,12 +1280,13 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
static int zynqmp_firmware_remove(struct platform_device *pdev) static int zynqmp_firmware_remove(struct platform_device *pdev)
{ {
struct pm_api_feature_data *feature_data; struct pm_api_feature_data *feature_data;
struct hlist_node *tmp;
int i; int i;
mfd_remove_devices(&pdev->dev); mfd_remove_devices(&pdev->dev);
zynqmp_pm_api_debugfs_exit(); zynqmp_pm_api_debugfs_exit();
hash_for_each(pm_api_features_map, i, feature_data, hentry) { hash_for_each_safe(pm_api_features_map, i, tmp, feature_data, hentry) {
hash_del(&feature_data->hentry); hash_del(&feature_data->hentry);
kfree(feature_data); kfree(feature_data);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment