Skip to content

Commit

Permalink
ipu6-isys: Fix ipu_isys_probe() error exit resource cleanup
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jwrdegoede committed May 1, 2024
1 parent e120647 commit ab8b8be
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions drivers/media/pci/intel/ipu-isys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit ab8b8be

Please sign in to comment.