From: Jan Rybar Date: Tue, 19 Feb 2019 15:39:17 +0000 (+0100) Subject: NULLptr sanity added in scan fns to avoid useless prep work (stalls NFS) X-Git-Tag: v23.3~20^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=499dfe62817f46e2132dd265dbe3603e5929279e;p=psmisc NULLptr sanity added in scan fns to avoid useless prep work (stalls NFS) --- diff --git a/src/fuser.c b/src/fuser.c index c44cee8..b8662a3 100644 --- a/src/fuser.c +++ b/src/fuser.c @@ -188,6 +188,9 @@ scan_procs(struct names *names_head, struct inode_list *ino_head, pid_t pid, my_pid; uid_t uid; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + if ((topproc_dir = opendir("/proc")) == NULL) { fprintf(stderr, _("Cannot open /proc directory: %s\n"), strerror(errno)); @@ -1873,6 +1876,10 @@ scan_knfsd(struct names *names_head, struct inode_list *ino_head, char *find_space; struct stat st; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + + if ((fp = fopen(KNFSD_EXPORTS, "r")) == NULL) { #ifdef DEBUG printf("Cannot open %s\n", KNFSD_EXPORTS); @@ -1919,6 +1926,10 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head, char *find_space; struct stat st; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + + if ((fp = fopen(PROC_MOUNTS, "r")) == NULL) { fprintf(stderr, "Cannot open %s\n", PROC_MOUNTS); return; @@ -1962,6 +1973,9 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, char *find_space; struct stat st; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + if ((fp = fopen(PROC_SWAPS, "r")) == NULL) { /*fprintf(stderr, "Cannot open %s\n", PROC_SWAPS); */ return;