Similar to libc free() allow NULL as a valid parameter to this freeing
routine. This mirrors the behavior of the other *_unref() routines in
the library.
Cc: Tiffany Kasanicky <tiffany.j.kasanicky(a)intel.com>
Reported-by: Linda Knippers <linda.knippers(a)hpe.com>
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
ndctl/lib/libndctl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 0722f79470c3..4b1247678a08 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -2122,6 +2122,8 @@ NDCTL_EXPORT int ndctl_dimm_zero_labels(struct ndctl_dimm *dimm)
NDCTL_EXPORT void ndctl_cmd_unref(struct ndctl_cmd *cmd)
{
+ if (!cmd)
+ return;
if (--cmd->refcount == 0) {
if (cmd->source)
ndctl_cmd_unref(cmd->source);