diff mbox

[ndctl] ndctl: permit NULL as a parameter to ndctl_cmd_unref

Message ID 146896920956.18759.7000784801515467749.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams July 19, 2016, 11 p.m. UTC
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@intel.com>
Reported-by: Linda Knippers <linda.knippers@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/lib/libndctl.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Johannes Thumshirn July 20, 2016, 7:56 a.m. UTC | #1
On Tue, Jul 19, 2016 at 04:00:09PM -0700, Dan Williams wrote:
> 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@intel.com>
> Reported-by: Linda Knippers <linda.knippers@hpe.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
diff mbox

Patch

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);