Skip to contentSkip to conversation

Staging: nvec: Fix pm_power_off reset condition in tegra_nvec_remove

PATCH In review Dima Volkovsk 4 participants 5 messages Feb 9, 2025 – Feb 12, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: nvec: Fix pm_power_off reset condition in tegra_nvec_remove

In the current implementation of tegra_nvec_remove, the pm_power_off handler is set to NULL without checking if it is actually set to nvec_power_off. This change ensures that pm_power_off is only reset if it was previously set to nvec_power_off, preventing unintended side effects when removing the device.

---
 drivers/staging/nvec/nvec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/nvec/nvec.c +4 -2
index 263774e6a78c..9057f061e927 100644
@@ -903,8 +903,10 @@ static void tegra_nvec_remove(struct platform_device *pdev)
 	nvec_unregister_notifier(nvec, &nvec->nvec_status_notifier);
 	cancel_work_sync(&nvec->rx_work);
 	cancel_work_sync(&nvec->tx_work);
-	/* FIXME: needs check whether nvec is responsible for power off */
-	pm_power_off = NULL;
+
+	/* only reset pm_power_off if it's our handler */
+	if (pm_power_off = nvec_power_off)
+		pm_power_off = NULL;
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.48.1
maintainer
#1 lore raw
Quoted 15 lines · Dima Volkovsk

In the current implementation of tegra_nvec_remove, the pm_power_off handler is set to NULL without checking if it is actually set to nvec_power_off. This change ensures that pm_power_off is only reset if it was previously set to nvec_power_off, preventing unintended side effects when removing the device.

---
 drivers/staging/nvec/nvec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/nvec/nvec.c +0 -0
index 263774e6a78c..9057f061e927 100644

drivers/staging/nvec/nvec.c static void tegra_nvec_remove(struct platform_device *pdev) · line 908

Quoted 8 lines
drivers/staging/nvec/nvec.c +3 -2
@@ -903,8 +903,10 @@ static void tegra_nvec_remove(struct platform_device *pdev)
 	nvec_unregister_notifier(nvec, &nvec->nvec_status_notifier);
 	cancel_work_sync(&nvec->rx_work);
 	cancel_work_sync(&nvec->tx_work);
-	/* FIXME: needs check whether nvec is responsible for power off */
-	pm_power_off = NULL;
+
+	/* only reset pm_power_off if it's our handler */
+	if (pm_power_off = nvec_power_off)

I don't think you tested this :(

#2 lore raw
In reply to Dima Volkovsk
kernel test robot noticed the following build warnings:

Hi Dima,

kernel test robot noticed the following build warnings:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/intel-lab-lkp/linux/commits/Dima-Volkovsk/Staging-nvec-Fix-pm_power_off-reset-condition-in-tegra_nvec_remove/20250210-041929
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/20250209201752.66313-1-s0ldw3ll%40gmail.com
patch subject: [PATCH] Staging: nvec: Fix pm_power_off reset condition in tegra_nvec_remove
config: arm-defconfig (https://download.01.org/0day-ci/archive/20250210/[email protected]/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 6807164500e9920638e2ab0cdb4bf8321d24f8eb)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250210/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/staging/nvec/nvec.c:908:19: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
     908 |         if (pm_power_off = nvec_power_off)
         |             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
   drivers/staging/nvec/nvec.c:908:19: note: place parentheses around the assignment to silence this warning
     908 |         if (pm_power_off = nvec_power_off)
         |                          ^               
         |             (                            )
   drivers/staging/nvec/nvec.c:908:19: note: use '==' to turn this assignment into an equality comparison
     908 |         if (pm_power_off = nvec_power_off)
         |                          ^
         |                          ==

1 warning generated.

vim +908 drivers/staging/nvec/nvec.c

896
897 static void tegra_nvec_remove(struct platform_device *pdev)
898 {
899 struct nvec_chip *nvec = platform_get_drvdata(pdev);
900
901 nvec_toggle_global_events(nvec, false);
902 mfd_remove_devices(nvec->dev);
903 nvec_unregister_notifier(nvec, &nvec->nvec_status_notifier);
904 cancel_work_sync(&nvec->rx_work);
905 cancel_work_sync(&nvec->tx_work);
906
907 /* only reset pm_power_off if it's our handler */

 > 908		if (pm_power_off = nvec_power_off)

909 pm_power_off = NULL;
910 }
911

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw
In reply to Dima Volkovsk
kernel test robot noticed the following build warnings:

Hi Dima,

kernel test robot noticed the following build warnings:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/intel-lab-lkp/linux/commits/Dima-Volkovsk/Staging-nvec-Fix-pm_power_off-reset-condition-in-tegra_nvec_remove/20250210-041929
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/20250209201752.66313-1-s0ldw3ll%40gmail.com
patch subject: [PATCH] Staging: nvec: Fix pm_power_off reset condition in tegra_nvec_remove
config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20250210/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250210/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/staging/nvec/nvec.c: In function 'tegra_nvec_remove':

>> drivers/staging/nvec/nvec.c:908:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]

908 | if (pm_power_off = nvec_power_off)
| ^~~~~~~~~~~~

vim +908 drivers/staging/nvec/nvec.c

896
897 static void tegra_nvec_remove(struct platform_device *pdev)
898 {
899 struct nvec_chip *nvec = platform_get_drvdata(pdev);
900
901 nvec_toggle_global_events(nvec, false);
902 mfd_remove_devices(nvec->dev);
903 nvec_unregister_notifier(nvec, &nvec->nvec_status_notifier);
904 cancel_work_sync(&nvec->rx_work);
905 cancel_work_sync(&nvec->tx_work);
906
907 /* only reset pm_power_off if it's our handler */

 > 908		if (pm_power_off = nvec_power_off)

909 pm_power_off = NULL;
910 }
911

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw
In reply to Dima Volkovsk
Quoted 6 lines · Dima Volkovsk

In the current implementation of tegra_nvec_remove, the pm_power_off handler is set to NULL without checking if it is actually set to nvec_power_off. This change ensures that pm_power_off is only reset if it was previously set to nvec_power_off, preventing unintended side effects when removing the device.

What everyone else said and also you forgot to add a Fixes tag.

regards,
dan carpenter