On 2020/12/17 11:33, Verma, Vishal L wrote:
> On Fri, 2020-11-06 at 17:27 +0800, Zhiqiang Liu wrote:
>> 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);
> 
> This looks good in general, but I made some small fixups while applying.
> Printing the bus provider here isn't as useful - I replaced it with
> printing the namespace 'devname':
> 
> -               err(ctx, "bus: %s failed to create cmd\n", 
> ndctl_bus_get_provider(bus));
> +               err(ctx, "%s: failed to create cmd\n",
> +                       ndctl_namespace_get_devname(ndns));
> 
> Also fixed up a couple of typos in commit messages, but otherwise the
> series looks good and I've applied it for v71.
> 

Thanks again.

Regards
Zhiqiang Liu

> Thanks,
> -Vishal
> 
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to