Commit 0a3f82c7 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

USB: uhci: fix memory leak with using debugfs_lookup()

When calling debugfs_lookup() the result must have dput() called on it,
otherwise the memory will leak over time.  To make things simpler, just
call debugfs_lookup_and_remove() instead which handles all of the logic
at once.

Cc: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20230202153235.2412790-3-gregkh@linuxfoundation.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8f4d25eb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -536,8 +536,8 @@ static void release_uhci(struct uhci_hcd *uhci)
	uhci->is_initialized = 0;
	spin_unlock_irq(&uhci->lock);

	debugfs_remove(debugfs_lookup(uhci_to_hcd(uhci)->self.bus_name,
				      uhci_debugfs_root));
	debugfs_lookup_and_remove(uhci_to_hcd(uhci)->self.bus_name,
				  uhci_debugfs_root);

	for (i = 0; i < UHCI_NUM_SKELQH; i++)
		uhci_free_qh(uhci, uhci->skelqh[i]);
@@ -700,7 +700,7 @@ static int uhci_start(struct usb_hcd *hcd)
			uhci->frame, uhci->frame_dma_handle);

err_alloc_frame:
	debugfs_remove(debugfs_lookup(hcd->self.bus_name, uhci_debugfs_root));
	debugfs_lookup_and_remove(hcd->self.bus_name, uhci_debugfs_root);

	return retval;
}