Skip to content

Commit

Permalink
USB: sl811: fix memory leak with using debugfs_lookup()
Browse files Browse the repository at this point in the history
[ Upstream commit e1523c4 ]

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: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/r/20230202153235.2412790-4-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
gregkh committed Mar 11, 2023
1 parent 9cb8884 commit 04fdfec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/host/sl811-hcd.c
Expand Up @@ -1501,7 +1501,7 @@ static void create_debug_file(struct sl811 *sl811)

static void remove_debug_file(struct sl811 *sl811)
{
debugfs_remove(debugfs_lookup("sl811h", usb_debug_root));
debugfs_lookup_and_remove("sl811h", usb_debug_root);
}

/*-------------------------------------------------------------------------*/
Expand Down

0 comments on commit 04fdfec

Please sign in to comment.