summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorLi Jun <jun.li@nxp.com>2019-07-17 16:06:46 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-16 10:12:42 +0200
commitbbc2e8206012504c9ba14fc9fd108a43a0d5201f (patch)
tree44e893ecc2e588d45eb770cf72a2938988d07f67 /drivers/usb
parent2ec5c9b785f4868cc94d30a28d55150f4c3bd39b (diff)
downloadlinux-stable-bbc2e8206012504c9ba14fc9fd108a43a0d5201f.tar.gz
linux-stable-bbc2e8206012504c9ba14fc9fd108a43a0d5201f.tar.bz2
linux-stable-bbc2e8206012504c9ba14fc9fd108a43a0d5201f.zip
usb: typec: tcpm: remove tcpm dir if no children
commit 12ca7297b8855c0af1848503d37196159b24e6b9 upstream. If config tcpm as module, module unload will not remove tcpm dir, then the next module load will have problem: the rootdir is NULL but tcpm dir is still there, so tcpm_debugfs_init() will create tcpm dir again with failure, fix it by remove the tcpm dir if no children. Cc: stable@vger.kernel.org # v4.15+ Fixes: 4b4e02c83167 ("typec: tcpm: Move out of staging") Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20190717080646.30421-2-jun.li@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/typec/tcpm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index d3f48374ad35..519b0f38dc6c 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -595,6 +595,10 @@ static void tcpm_debugfs_exit(struct tcpm_port *port)
mutex_unlock(&port->logbuffer_lock);
debugfs_remove(port->dentry);
+ if (list_empty(&rootdir->d_subdirs)) {
+ debugfs_remove(rootdir);
+ rootdir = NULL;
+ }
}
#else