Static analysis reports that can potentially dereference a NULL pointer in the smart cmd error handler. This can particular instance won't ever be hit in practice as the handler is only registered for smart commands, and smart commands are currently only DIMM commands, and will always have a dimm object. However for completeness, and to avoid future errors, we should perform a NULL check in the handler anyway.
Cc: Keith Busch <[email protected]> Fixes: ba17700bf227 ("ndctl, intel: Fallback to smart cached shutdown_count") Signed-off-by: Vishal Verma <[email protected]> --- ndctl/lib/intel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c index 00c65a5..b1254bb 100644 --- a/ndctl/lib/intel.c +++ b/ndctl/lib/intel.c @@ -67,6 +67,9 @@ static int intel_smart_handle_error(struct ndctl_cmd *cmd) char *path = NULL, shutdown_count[16] = {}; int fd, rc = cmd->status; + if (!dimm) + return 0; + if (asprintf(&path, DEF_TMPFS_DIR "/%s/usc", ndctl_dimm_get_devname(dimm)) < 0) return rc; -- 2.14.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
