Skip to contentSkip to conversation

iommu/amd: Improve amd_iommu_v2_exit()

bug report Dan Carpenter 1 participant 1 message Mar 9, 2022

lore
Share & tools
lore
#0 lore raw

Hello Suravee Suthikulpanit,

The patch d46c04558fdd: "iommu/amd: Improve amd_iommu_v2_exit()" from Mar 1, 2022, leads to the following Smatch static checker warning:

	drivers/iommu/amd/iommu_v2.c:133 free_device_state()
	warn: sleeping in atomic context

drivers/iommu/amd/iommu_v2.c
955 static void __exit amd_iommu_v2_exit(void)
956 {
957 struct device_state *dev_state, *next;
958 unsigned long flags;
959
960 if (!amd_iommu_v2_supported())
961 return;
962
963 amd_iommu_unregister_ppr_notifier(&ppr_nb);
964
965 flush_workqueue(iommu_wq);
966
967 /*

   968                 * The loop below might call flush_workqueue(), so call
   969                 * destroy_workqueue() after it
   970                 */

971 spin_lock_irqsave(&state_lock, flags);

Holding a spin lock.

   972
   973                list_for_each_entry_safe(dev_state, next, &state_list, list) {
   974                        WARN_ON_ONCE(1);
   975
   976                        put_device_state(dev_state);
   977                        list_del(&dev_state->list);
   978                        free_device_state(dev_state);

Calling a sleeping function (wait_event()).

   979                }
   980
   981                spin_unlock_irqrestore(&state_lock, flags);
   982
   983                destroy_workqueue(iommu_wq);
   984        }

regards,
dan carpenter
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu