Remove the redundant code

proc_remove does nothing when the argument is NULL[1]. We don't need
proc_remove after proc_create failed.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/proc/generic.c#n789
This commit is contained in:
Bob Lee 2024-10-06 14:25:49 +08:00
parent 3a09a1e473
commit 8c641a2deb
No known key found for this signature in database
GPG Key ID: 0DA954476306EEFA

View File

@ -48,7 +48,6 @@ static int __init procfs1_init(void)
{ {
our_proc_file = proc_create(procfs_name, 0644, NULL, &proc_file_fops); our_proc_file = proc_create(procfs_name, 0644, NULL, &proc_file_fops);
if (NULL == our_proc_file) { if (NULL == our_proc_file) {
proc_remove(our_proc_file);
pr_alert("Error:Could not initialize /proc/%s\n", procfs_name); pr_alert("Error:Could not initialize /proc/%s\n", procfs_name);
return -ENOMEM; return -ENOMEM;
} }