From: Sami Kerola Date: Sat, 18 May 2019 21:14:20 +0000 (+0100) Subject: libmount: avoid possible null pointer dereference [cppcheck] X-Git-Tag: v2.34-rc2~51^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cbcedf6ba83b0929ad21e227db62883886d2ccce;p=thirdparty%2Futil-linux.git libmount: avoid possible null pointer dereference [cppcheck] [libmount/src/monitor.c:797]: (warning) Possible null pointer dereference: me Signed-off-by: Sami Kerola --- diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c index 2383a734af..730c8bdea4 100644 --- a/libmount/src/monitor.c +++ b/libmount/src/monitor.c @@ -794,14 +794,17 @@ int mnt_monitor_next_change(struct libmnt_monitor *mn, me = NULL; } - me->changed = 0; + if (me) { + me->changed = 0; - if (filename) - *filename = me->path; - if (type) - *type = me->type; + if (filename) + *filename = me->path; + if (type) + *type = me->type; - DBG(MONITOR, ul_debugobj(mn, " *** success [changed: %s]", me->path)); + DBG(MONITOR, ul_debugobj(mn, " *** success [changed: %s]", me->path)); + } else + return -EINVAL; return 0; /* success */ }