All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
To: "Verma, Vishal L" <vishal.l.verma@intel.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
	"linfeilong@huawei.com" <linfeilong@huawei.com>
Subject: Re: [ndctl PATCH 6/8] lib/inject: check whether cmd is created successfully
Date: Thu, 17 Dec 2020 14:19:38 +0800	[thread overview]
Message-ID: <57407095-029d-0631-51cb-9970007e6b0c@huawei.com> (raw)
In-Reply-To: <a75b781d2d838242930633f9f3c70c67df248849.camel@intel.com>

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 <liuzhiqiang26@huawei.com>
>> ---
>>  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 -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

  reply	other threads:[~2020-12-17  6:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06  9:23 [ndctl PATCH 0/8] fix serverl issues reported by Coverity Zhiqiang Liu
2020-11-06  9:24 ` [ndctl PATCH 1/8] namespace: check whether pfn|dax|btt is NULL in setup_namespace Zhiqiang Liu
2020-11-20 16:29   ` Jeff Moyer
2020-11-06  9:25 ` [ndctl PATCH 2/8] lib/libndctl: fix memory leakage problem in add_bus Zhiqiang Liu
2020-11-20 16:31   ` Jeff Moyer
2020-11-06  9:25 ` [ndctl PATCH 3/8] libdaxctl: fix memory leakage in add_dax_region() Zhiqiang Liu
2020-11-20 16:33   ` Jeff Moyer
2020-11-06  9:26 ` [ndctl PATCH 4/8] dimm: fix potential fd leakage in dimm_action() Zhiqiang Liu
2020-11-20 16:36   ` Jeff Moyer
2020-11-06  9:26 ` [ndctl PATCH 5/8] util/help: check whether strdup returns NULL in exec_man_konqueror Zhiqiang Liu
2020-11-06  9:27 ` [ndctl PATCH 6/8] lib/inject: check whether cmd is created successfully Zhiqiang Liu
2020-12-17  3:33   ` Verma, Vishal L
2020-12-17  6:19     ` Zhiqiang Liu [this message]
2020-11-06  9:27 ` [ndctl PATCH 7/8] Check whether ndctl_btt_get_namespace returns NULL in callers Zhiqiang Liu
2020-11-06  9:28 ` [ndctl PATCH 8/8] Check whether seed is NULL in validate_namespace_options Zhiqiang Liu
2020-11-10 10:58 ` [ndctl PATCH 0/8] fix serverl issues reported by Coverity Zhiqiang Liu
2020-11-20  2:45 ` Zhiqiang Liu
2020-11-20  2:47   ` Verma, Vishal L
2020-11-20  3:01     ` Zhiqiang Liu
2020-11-20 16:45 ` Jeff Moyer
2020-11-23  0:47   ` Zhiqiang Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57407095-029d-0631-51cb-9970007e6b0c@huawei.com \
    --to=liuzhiqiang26@huawei.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.