All of lore.kernel.org
 help / color / mirror / Atom feed
From: hare@suse.com (Hannes Reinecke)
Subject: [PATCH 2/5] nvmet: fixup crash on NULL device path
Date: Tue, 17 Jul 2018 15:48:41 +0200	[thread overview]
Message-ID: <f4775b23-c601-6e57-c892-be88a23c5cf3@suse.com> (raw)
In-Reply-To: <20180717134841.GA16604@lst.de>

On 07/17/2018 03:48 PM, Christoph Hellwig wrote:
> On Mon, Jul 16, 2018@12:58:34PM +0200, Hannes Reinecke wrote:
>> index 094d216ae62a..76efc8120c00 100644
>> --- a/drivers/nvme/target/configfs.c
>> +++ b/drivers/nvme/target/configfs.c
>> @@ -295,6 +295,12 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
>>  	ns->device_path = kstrndup(page, strcspn(page, "\n"), GFP_KERNEL);
>>  	if (!ns->device_path)
>>  		goto out_unlock;
>> +	if (!strlen(ns->device_path)) {
>> +		kfree(ns->device_path);
>> +		ns->device_path = NULL;
>> +		ret = -EINVAL;
>> +		goto out_unlock;
>> +	}
> 
> I think this should rather be:
> 
> 	ret = -EINVAL;
> 	len = strcspn(page, "\n");
> 	if (len == 0)
> 		goto out_unlock;
> 	ret = -ENOMEM;
> 	ns->device_path = kstrndup(page, len, GFP_KERNEL);
> 	if (!ns->device_path)
> 		goto out_unlock;
> 
Okay.

>> index 0aeccbddd716..956d293d293d 100644
>> --- a/drivers/nvme/target/core.c
>> +++ b/drivers/nvme/target/core.c
>> @@ -373,8 +373,12 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
>>  	if (ns->enabled)
>>  		goto out_unlock;
>>  
>> +	if (!ns->device_path) {
>> +		ret = -EINVAL;
>> +		goto out_unlock;
>> +	}
> 
> I don't think we should need this fix.
> 
>>  	ret = nvmet_bdev_ns_enable(ns);
>> -	if (ret)
>> +	if (ret == -ENOTBLK)
>>  		ret = nvmet_file_ns_enable(ns);
> 
> Looks sensible, but please split this into a separate patch.
> 
Right. And should be sent independently of the ANA stuff, too.

Will be updating both.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare at suse.com			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

  reply	other threads:[~2018-07-17 13:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 10:58 [PATCH 0/5] nvme: ANA implementation fixes Hannes Reinecke
2018-07-16 10:58 ` [PATCH 1/5] nvme: count all ANA groups for ANA Log page Hannes Reinecke
2018-07-19 14:31   ` Christoph Hellwig
2018-09-17 13:49   ` Christoph Hellwig
2018-07-16 10:58 ` [PATCH 2/5] nvmet: fixup crash on NULL device path Hannes Reinecke
2018-07-17 13:48   ` Christoph Hellwig
2018-07-17 13:48     ` Hannes Reinecke [this message]
2018-07-17 13:55       ` Christoph Hellwig
2018-07-24 14:02       ` Christoph Hellwig
2018-07-25  7:25         ` Hannes Reinecke
2018-07-16 10:58 ` [PATCH 3/5] nvme-multipath: fixup crash during disconnect Hannes Reinecke
2018-07-19 14:31   ` Christoph Hellwig
2018-07-19 14:35     ` Christoph Hellwig
2018-07-16 10:58 ` [PATCH 4/5] nvme-multipath: disable ANA support if parsing fails Hannes Reinecke
2018-07-19 14:43   ` Christoph Hellwig
2018-07-19 16:00     ` Hannes Reinecke
2018-07-20 15:00       ` Christoph Hellwig
2018-07-16 10:58 ` [PATCH 5/5] nvme-multipath: parse entire ANA log page in nvme_set_ns_ana_state() Hannes Reinecke
2018-07-19 14:46   ` Christoph Hellwig

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=f4775b23-c601-6e57-c892-be88a23c5cf3@suse.com \
    --to=hare@suse.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.