From: AntonMoryakov Date: Tue, 14 Jan 2025 15:06:49 +0000 (+0300) Subject: sys-utils: fix add NULL check for mnt_fs_get_target return value X-Git-Tag: v2.42-start~89^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0fabec8c7fda554b79327d8713352e7a07539895;p=thirdparty%2Futil-linux.git sys-utils: fix add NULL check for mnt_fs_get_target return value The static analyzer flagged a potential issue: the return value of mnt_fs_get_target(fs) could be NULL, but it was dereferenced without a check. This could lead to undefined behavior. Added a NULL check before using the tgt pointer. If tgt is NULL, the current iteration is skipped. ChanChanges: - Added if (!tgt) check before using tgt. Signed-off-by: Anton Moryakov --- diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index 500bc013c..93bbd758b 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -1132,6 +1132,9 @@ static int nsfs_xasputs(char **str, const char *tgt = mnt_fs_get_target(fs); + if(!tgt) + continue; + if (!*str) xasprintf(str, "%s", tgt);