All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: firmware: xilinx: Fix dereferencing freed memory
@ 2021-02-08  6:31 ` Rajan Vaja
  0 siblings, 0 replies; 4+ messages in thread
From: Rajan Vaja @ 2021-02-08  6:31 UTC (permalink / raw)
  To: amit.sunil.dhamne, michal.simek
  Cc: linux-arm-kernel, linux-kernel, Tejas Patel, Rajan Vaja

From: Tejas Patel <tejas.patel@xilinx.com>

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: acfdd18591ea ("firmware: xilinx: Use hash-table for api feature check")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tejas Patel <tejas.patel@xilinx.com>
Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 7eb9958..83082e2 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -2,7 +2,7 @@
 /*
  * Xilinx Zynq MPSoC Firmware layer
  *
- *  Copyright (C) 2014-2020 Xilinx, Inc.
+ *  Copyright (C) 2014-2021 Xilinx, Inc.
  *
  *  Michal Simek <michal.simek@xilinx.com>
  *  Davorin Mista <davorin.mista@aggios.com>
@@ -1280,12 +1280,13 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
 static int zynqmp_firmware_remove(struct platform_device *pdev)
 {
 	struct pm_api_feature_data *feature_data;
+	struct hlist_node *tmp;
 	int i;
 
 	mfd_remove_devices(&pdev->dev);
 	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);
 		kfree(feature_data);
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] drivers: firmware: xilinx: Fix dereferencing freed memory
@ 2021-02-08  6:31 ` Rajan Vaja
  0 siblings, 0 replies; 4+ messages in thread
From: Rajan Vaja @ 2021-02-08  6:31 UTC (permalink / raw)
  To: amit.sunil.dhamne, michal.simek
  Cc: Tejas Patel, Rajan Vaja, linux-kernel, linux-arm-kernel

From: Tejas Patel <tejas.patel@xilinx.com>

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: acfdd18591ea ("firmware: xilinx: Use hash-table for api feature check")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tejas Patel <tejas.patel@xilinx.com>
Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 7eb9958..83082e2 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -2,7 +2,7 @@
 /*
  * Xilinx Zynq MPSoC Firmware layer
  *
- *  Copyright (C) 2014-2020 Xilinx, Inc.
+ *  Copyright (C) 2014-2021 Xilinx, Inc.
  *
  *  Michal Simek <michal.simek@xilinx.com>
  *  Davorin Mista <davorin.mista@aggios.com>
@@ -1280,12 +1280,13 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
 static int zynqmp_firmware_remove(struct platform_device *pdev)
 {
 	struct pm_api_feature_data *feature_data;
+	struct hlist_node *tmp;
 	int i;
 
 	mfd_remove_devices(&pdev->dev);
 	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);
 		kfree(feature_data);
 	}
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drivers: firmware: xilinx: Fix dereferencing freed memory
  2021-02-08  6:31 ` Rajan Vaja
@ 2021-02-12 14:12   ` Michal Simek
  -1 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2021-02-12 14:12 UTC (permalink / raw)
  To: Rajan Vaja, amit.sunil.dhamne, michal.simek
  Cc: linux-arm-kernel, linux-kernel, Tejas Patel



On 2/8/21 7:31 AM, Rajan Vaja wrote:
> From: Tejas Patel <tejas.patel@xilinx.com>
> 
> 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: acfdd18591ea ("firmware: xilinx: Use hash-table for api feature check")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Tejas Patel <tejas.patel@xilinx.com>
> Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com>
> ---
>  drivers/firmware/xilinx/zynqmp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index 7eb9958..83082e2 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -2,7 +2,7 @@
>  /*
>   * Xilinx Zynq MPSoC Firmware layer
>   *
> - *  Copyright (C) 2014-2020 Xilinx, Inc.
> + *  Copyright (C) 2014-2021 Xilinx, Inc.
>   *
>   *  Michal Simek <michal.simek@xilinx.com>
>   *  Davorin Mista <davorin.mista@aggios.com>
> @@ -1280,12 +1280,13 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
>  static int zynqmp_firmware_remove(struct platform_device *pdev)
>  {
>  	struct pm_api_feature_data *feature_data;
> +	struct hlist_node *tmp;
>  	int i;
>  
>  	mfd_remove_devices(&pdev->dev);
>  	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);
>  		kfree(feature_data);
>  	}
> 

Applied.

Thanks,
Michal


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drivers: firmware: xilinx: Fix dereferencing freed memory
@ 2021-02-12 14:12   ` Michal Simek
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2021-02-12 14:12 UTC (permalink / raw)
  To: Rajan Vaja, amit.sunil.dhamne, michal.simek
  Cc: Tejas Patel, linux-kernel, linux-arm-kernel



On 2/8/21 7:31 AM, Rajan Vaja wrote:
> From: Tejas Patel <tejas.patel@xilinx.com>
> 
> 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: acfdd18591ea ("firmware: xilinx: Use hash-table for api feature check")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Tejas Patel <tejas.patel@xilinx.com>
> Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com>
> ---
>  drivers/firmware/xilinx/zynqmp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index 7eb9958..83082e2 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -2,7 +2,7 @@
>  /*
>   * Xilinx Zynq MPSoC Firmware layer
>   *
> - *  Copyright (C) 2014-2020 Xilinx, Inc.
> + *  Copyright (C) 2014-2021 Xilinx, Inc.
>   *
>   *  Michal Simek <michal.simek@xilinx.com>
>   *  Davorin Mista <davorin.mista@aggios.com>
> @@ -1280,12 +1280,13 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
>  static int zynqmp_firmware_remove(struct platform_device *pdev)
>  {
>  	struct pm_api_feature_data *feature_data;
> +	struct hlist_node *tmp;
>  	int i;
>  
>  	mfd_remove_devices(&pdev->dev);
>  	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);
>  		kfree(feature_data);
>  	}
> 

Applied.

Thanks,
Michal


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-12 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08  6:31 [PATCH] drivers: firmware: xilinx: Fix dereferencing freed memory Rajan Vaja
2021-02-08  6:31 ` Rajan Vaja
2021-02-12 14:12 ` Michal Simek
2021-02-12 14:12   ` Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.