ndctl_bus_cmd_new_ars_cp() is called to create cmd,
which may return NULL. We need to check whether it
is NULL in callers, such as ndctl_namespace_get_clear_uint
and ndctl_namespace_injection_status.

Signed-off-by: Zhiqiang Liu <[email protected]>
---
 ndctl/lib/inject.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ndctl/lib/inject.c b/ndctl/lib/inject.c
index 815f254..b543fc7 100644
--- a/ndctl/lib/inject.c
+++ b/ndctl/lib/inject.c
@@ -114,6 +114,10 @@ static int ndctl_namespace_get_clear_unit(struct 
ndctl_namespace *ndns)
        if (rc)
                return rc;
        cmd = ndctl_bus_cmd_new_ars_cap(bus, ns_offset, ns_size);
+       if (!cmd) {
+               err(ctx, "bus: %s failed to create cmd\n", 
ndctl_bus_get_provider(bus));
+               return -ENOTTY;
+       }
        rc = ndctl_cmd_submit(cmd);
        if (rc < 0) {
                dbg(ctx, "Error submitting ars_cap: %d\n", rc);
@@ -457,6 +461,10 @@ NDCTL_EXPORT int ndctl_namespace_injection_status(struct 
ndctl_namespace *ndns)
                        return rc;

                cmd = ndctl_bus_cmd_new_ars_cap(bus, ns_offset, ns_size);
+               if (!cmd) {
+                       err(ctx, "bus: %s failed to create cmd\n", 
ndctl_bus_get_provider(bus));
+                       return -ENOTTY;
+               }
                rc = ndctl_cmd_submit(cmd);
                if (rc < 0) {
                        dbg(ctx, "Error submitting ars_cap: %d\n", rc);
-- 
1.8.3.1


_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to