From 562e6c175be9f74add6f10c7cd91a82839a4b8d6 Mon Sep 17 00:00:00 2001 From: Nitesh Gupta Date: Mon, 12 Oct 2020 15:44:03 +0530 Subject: [PATCH] mhi: dev: netdev: Update logic for valid access of dentry variable Variable "dentry" is valid only if "CONFIG_DEBUG_FS" is set. Update logic such that "dentry" variable is accessed during debugfs removal only in valid condition. Change-Id: I2a1e3e7f312cf316c94e930e15e9528fbeedb9a1 Signed-off-by: Nitesh Gupta --- drivers/bus/mhi/devices/mhi_netdev.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/bus/mhi/devices/mhi_netdev.c b/drivers/bus/mhi/devices/mhi_netdev.c index b86a2dc9e12c..1187410ab5fc 100644 --- a/drivers/bus/mhi/devices/mhi_netdev.c +++ b/drivers/bus/mhi/devices/mhi_netdev.c @@ -918,9 +918,14 @@ static void mhi_netdev_create_debugfs_dir(void) dentry = debugfs_create_dir(MHI_NETDEV_DRIVER_NAME, 0); } +static void mhi_netdev_debugfs_remove(void) +{ + debugfs_remove_recursive(dentry); +} + #else -static void mhi_netdev_create_debugfs(struct mhi_netdev_private *mhi_netdev) +static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev) { } @@ -928,6 +933,10 @@ static void mhi_netdev_create_debugfs_dir(void) { } +static void mhi_netdev_debugfs_remove(void) +{ +} + #endif static void mhi_netdev_remove(struct mhi_device *mhi_dev) @@ -1141,8 +1150,7 @@ module_init(mhi_netdev_init); static void __exit mhi_netdev_exit(void) { - debugfs_remove_recursive(dentry); - + mhi_netdev_debugfs_remove(); mhi_driver_unregister(&mhi_netdev_driver); } module_exit(mhi_netdev_exit);