Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/hfi1: Fix module use count flaw due to leftover module put calls

When the try_module_get calls were removed from opening and closing of the
i2c debugfs file, the corresponding module_put calls were missed. This
results in an inaccurate module use count that requires a power cycle to
fix.

Fixes: 09fbca8e6240 ("IB/hfi1: No need to use try_module_get for debugfs")
Link: https://lore.kernel.org/r/20200623203230.106975.76240.stgit@awfm-01.aw.intel.com
Cc: <stable@vger.kernel.org>
Reviewed-by: Kaike Wan <kaike.wan@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Dennis Dalessandro and committed by
Jason Gunthorpe
822fbd37 b46925a2

+2 -17
+2 -17
drivers/infiniband/hw/hfi1/debugfs.c
··· 985 985 static int __i2c_debugfs_open(struct inode *in, struct file *fp, u32 target) 986 986 { 987 987 struct hfi1_pportdata *ppd; 988 - int ret; 989 988 990 989 ppd = private2ppd(fp); 991 990 992 - ret = acquire_chip_resource(ppd->dd, i2c_target(target), 0); 993 - if (ret) /* failed - release the module */ 994 - module_put(THIS_MODULE); 995 - 996 - return ret; 991 + return acquire_chip_resource(ppd->dd, i2c_target(target), 0); 997 992 } 998 993 999 994 static int i2c1_debugfs_open(struct inode *in, struct file *fp) ··· 1008 1013 ppd = private2ppd(fp); 1009 1014 1010 1015 release_chip_resource(ppd->dd, i2c_target(target)); 1011 - module_put(THIS_MODULE); 1012 1016 1013 1017 return 0; 1014 1018 } ··· 1025 1031 static int __qsfp_debugfs_open(struct inode *in, struct file *fp, u32 target) 1026 1032 { 1027 1033 struct hfi1_pportdata *ppd; 1028 - int ret; 1029 - 1030 - if (!try_module_get(THIS_MODULE)) 1031 - return -ENODEV; 1032 1034 1033 1035 ppd = private2ppd(fp); 1034 1036 1035 - ret = acquire_chip_resource(ppd->dd, i2c_target(target), 0); 1036 - if (ret) /* failed - release the module */ 1037 - module_put(THIS_MODULE); 1038 - 1039 - return ret; 1037 + return acquire_chip_resource(ppd->dd, i2c_target(target), 0); 1040 1038 } 1041 1039 1042 1040 static int qsfp1_debugfs_open(struct inode *in, struct file *fp) ··· 1048 1062 ppd = private2ppd(fp); 1049 1063 1050 1064 release_chip_resource(ppd->dd, i2c_target(target)); 1051 - module_put(THIS_MODULE); 1052 1065 1053 1066 return 0; 1054 1067 }