From ab8b8bea5c510342e008cae0dc8cc1b7b8c30c99 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 5 Mar 2024 18:14:50 +0100 Subject: [PATCH] ipu6-isys: Fix ipu_isys_probe() error exit resource cleanup Add a bunch of missing resource cleanups to ipu_isys_probe()'s error exit path. Add a missing mutex_destroy() to isys_remove() and drop the always true "if (isp->ipu_dir)" check before calling debugfs_remove_recursive(). This likely should have checked the debugfs_remove_recursive() argument is not NULL but that is not necessary, debugfs_remove_recursive() checks this itself. Signed-off-by: Hans de Goede --- drivers/media/pci/intel/ipu-isys.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/intel/ipu-isys.c b/drivers/media/pci/intel/ipu-isys.c index 24c0af786a49..eb4fba3a0a80 100644 --- a/drivers/media/pci/intel/ipu-isys.c +++ b/drivers/media/pci/intel/ipu-isys.c @@ -1170,8 +1170,7 @@ static void isys_remove(struct ipu_bus_device *adev) dev_info(&adev->dev, "removed\n"); #ifdef CONFIG_DEBUG_FS - if (isp->ipu_dir) - debugfs_remove_recursive(isys->debugfsdir); + debugfs_remove_recursive(isys->debugfsdir); #endif list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) { @@ -1217,6 +1216,7 @@ static void isys_remove(struct ipu_bus_device *adev) mutex_destroy(&isys->stream_mutex); mutex_destroy(&isys->mutex); + mutex_destroy(&isys->lib_mutex); if (isys->short_packet_source == IPU_ISYS_SHORT_PACKET_FROM_TUNIT) { u32 trace_size = IPU_ISYS_SHORT_PACKET_TRACE_BUFFER_SIZE; @@ -1587,7 +1587,15 @@ static int isys_probe(struct ipu_bus_device *adev) isys_iwake_watermark_cleanup(isys); isys_unregister_devices(isys); out_remove_pkg_dir_shared_buffer: +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) cpu_latency_qos_remove_request(&isys->pm_qos); +#else + pm_qos_remove_request(&isys->pm_qos); +#endif + ipu_trace_uninit(&adev->dev); +#ifdef CONFIG_DEBUG_FS + debugfs_remove_recursive(isys->debugfsdir); +#endif if (!isp->secure_mode) ipu_cpd_free_pkg_dir(adev, isys->pkg_dir, isys->pkg_dir_dma_addr, @@ -1598,10 +1606,10 @@ static int isys_probe(struct ipu_bus_device *adev) release_firmware: if (!isp->secure_mode) release_firmware(isys->fw); - ipu_trace_uninit(&adev->dev); mutex_destroy(&isys->mutex); mutex_destroy(&isys->stream_mutex); + mutex_destroy(&isys->lib_mutex); if (isys->short_packet_source == IPU_ISYS_SHORT_PACKET_FROM_TUNIT) mutex_destroy(&isys->short_packet_tracing_mutex);