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

locking/debug: Fix debugfs API return value checks to use IS_ERR()

Update the checking of return values from debugfs_create_file()
and debugfs_create_dir() to use IS_ERR().

Signed-off-by: Atul Kumar Pant <atulpant.linux@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Waiman Long <longman@redhat.com>
Link: https://lore.kernel.org/r/20230807121834.7438-1-atulpant.linux@gmail.com

authored by

Atul Kumar Pant and committed by
Ingo Molnar
8788c6c2 cfa92b6d

+5 -5
+5 -5
kernel/locking/lock_events.c
··· 146 146 struct dentry *d_counts = debugfs_create_dir(LOCK_EVENTS_DIR, NULL); 147 147 int i; 148 148 149 - if (!d_counts) 149 + if (IS_ERR(d_counts)) 150 150 goto out; 151 151 152 152 /* ··· 159 159 for (i = 0; i < lockevent_num; i++) { 160 160 if (skip_lockevent(lockevent_names[i])) 161 161 continue; 162 - if (!debugfs_create_file(lockevent_names[i], 0400, d_counts, 163 - (void *)(long)i, &fops_lockevent)) 162 + if (IS_ERR(debugfs_create_file(lockevent_names[i], 0400, d_counts, 163 + (void *)(long)i, &fops_lockevent))) 164 164 goto fail_undo; 165 165 } 166 166 167 - if (!debugfs_create_file(lockevent_names[LOCKEVENT_reset_cnts], 0200, 167 + if (IS_ERR(debugfs_create_file(lockevent_names[LOCKEVENT_reset_cnts], 0200, 168 168 d_counts, (void *)(long)LOCKEVENT_reset_cnts, 169 - &fops_lockevent)) 169 + &fops_lockevent))) 170 170 goto fail_undo; 171 171 172 172 return 0;