* [PATCH] libnvdimm, namespace: check nsblk->uuid immediately after its allocation
@ 2019-01-16 6:51 Wei Yang
2019-06-04 3:10 ` Wei Yang
0 siblings, 1 reply; 4+ messages in thread
From: Wei Yang @ 2019-01-16 6:51 UTC (permalink / raw)
To: linux-nvdimm; +Cc: zwisler
When creating nd_namespace_blk, its uuid is copied from nd_label->uuid.
In case the memory allocation fails, it goes to the error branch.
This check is better to be done immediately after memory allocation,
while current implementation does this after assigning claim_class.
This patch moves the check immediately after uuid allocation.
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
drivers/nvdimm/namespace_devs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 681af3a8fd62..9471b9ca04f5 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2240,11 +2240,11 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
nsblk->lbasize = __le64_to_cpu(nd_label->lbasize);
nsblk->uuid = kmemdup(nd_label->uuid, NSLABEL_UUID_LEN,
GFP_KERNEL);
+ if (!nsblk->uuid)
+ goto blk_err;
if (namespace_label_has(ndd, abstraction_guid))
nsblk->common.claim_class
= to_nvdimm_cclass(&nd_label->abstraction_guid);
- if (!nsblk->uuid)
- goto blk_err;
memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
if (name[0])
nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
--
2.19.1
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] libnvdimm, namespace: check nsblk->uuid immediately after its allocation
2019-01-16 6:51 [PATCH] libnvdimm, namespace: check nsblk->uuid immediately after its allocation Wei Yang
@ 2019-06-04 3:10 ` Wei Yang
2019-06-25 22:06 ` Dan Williams
0 siblings, 1 reply; 4+ messages in thread
From: Wei Yang @ 2019-06-04 3:10 UTC (permalink / raw)
To: Wei Yang; +Cc: zwisler, linux-nvdimm
Hi, Dan
Do you have some time on this?
On Wed, Jan 16, 2019 at 02:51:44PM +0800, Wei Yang wrote:
>When creating nd_namespace_blk, its uuid is copied from nd_label->uuid.
>In case the memory allocation fails, it goes to the error branch.
>
>This check is better to be done immediately after memory allocation,
>while current implementation does this after assigning claim_class.
>
>This patch moves the check immediately after uuid allocation.
>
>Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>---
> drivers/nvdimm/namespace_devs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
>index 681af3a8fd62..9471b9ca04f5 100644
>--- a/drivers/nvdimm/namespace_devs.c
>+++ b/drivers/nvdimm/namespace_devs.c
>@@ -2240,11 +2240,11 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
> nsblk->lbasize = __le64_to_cpu(nd_label->lbasize);
> nsblk->uuid = kmemdup(nd_label->uuid, NSLABEL_UUID_LEN,
> GFP_KERNEL);
>+ if (!nsblk->uuid)
>+ goto blk_err;
> if (namespace_label_has(ndd, abstraction_guid))
> nsblk->common.claim_class
> = to_nvdimm_cclass(&nd_label->abstraction_guid);
>- if (!nsblk->uuid)
>- goto blk_err;
> memcpy(name, nd_label->name, NSLABEL_NAME_LEN);
> if (name[0])
> nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN,
>--
>2.19.1
--
Wei Yang
Help you, Help me
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libnvdimm, namespace: check nsblk->uuid immediately after its allocation
2019-06-04 3:10 ` Wei Yang
@ 2019-06-25 22:06 ` Dan Williams
2019-06-26 0:26 ` Wei Yang
0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2019-06-25 22:06 UTC (permalink / raw)
To: Wei Yang; +Cc: Ross Zwisler, linux-nvdimm
On Mon, Jun 3, 2019 at 8:11 PM Wei Yang <richardw.yang@linux.intel.com> wrote:
>
> Hi, Dan
>
> Do you have some time on this?
>
> On Wed, Jan 16, 2019 at 02:51:44PM +0800, Wei Yang wrote:
> >When creating nd_namespace_blk, its uuid is copied from nd_label->uuid.
> >In case the memory allocation fails, it goes to the error branch.
> >
> >This check is better to be done immediately after memory allocation,
> >while current implementation does this after assigning claim_class.
> >
> >This patch moves the check immediately after uuid allocation.
This looks ok, but the patch has no significant impact. I'm not
particularly motivated to carry it forward.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libnvdimm, namespace: check nsblk->uuid immediately after its allocation
2019-06-25 22:06 ` Dan Williams
@ 2019-06-26 0:26 ` Wei Yang
0 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2019-06-26 0:26 UTC (permalink / raw)
To: Dan Williams; +Cc: Ross Zwisler, linux-nvdimm
On Tue, Jun 25, 2019 at 03:06:42PM -0700, Dan Williams wrote:
>On Mon, Jun 3, 2019 at 8:11 PM Wei Yang <richardw.yang@linux.intel.com> wrote:
>>
>> Hi, Dan
>>
>> Do you have some time on this?
>>
>> On Wed, Jan 16, 2019 at 02:51:44PM +0800, Wei Yang wrote:
>> >When creating nd_namespace_blk, its uuid is copied from nd_label->uuid.
>> >In case the memory allocation fails, it goes to the error branch.
>> >
>> >This check is better to be done immediately after memory allocation,
>> >while current implementation does this after assigning claim_class.
>> >
>> >This patch moves the check immediately after uuid allocation.
>
>This looks ok, but the patch has no significant impact. I'm not
>particularly motivated to carry it forward.
Got it. Thanks
--
Wei Yang
Help you, Help me
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-26 0:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 6:51 [PATCH] libnvdimm, namespace: check nsblk->uuid immediately after its allocation Wei Yang
2019-06-04 3:10 ` Wei Yang
2019-06-25 22:06 ` Dan Williams
2019-06-26 0:26 ` Wei Yang
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.