All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] libnvdimm, namespace: potential NULL deref on allocation error
@ 2016-10-12  6:34 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-10-12  6:34 UTC (permalink / raw)
  To: Dan Williams
  Cc: linux-nvdimm-y27Ovi1pjclAfugRpC6u6w,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

If the kcalloc() fails then "devs" can be NULL and we dereference it
checking "devs[i]".

Fixes: 1b40e09a1232 ('libnvdimm: blk labels and namespace instantiation')
Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 3509cff..abe5c6b 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2176,12 +2176,14 @@ static struct device **scan_labels(struct nd_region *nd_region)
 	return devs;
 
  err:
-	for (i = 0; devs[i]; i++)
-		if (is_nd_blk(&nd_region->dev))
-			namespace_blk_release(devs[i]);
-		else
-			namespace_pmem_release(devs[i]);
-	kfree(devs);
+	if (devs) {
+		for (i = 0; devs[i]; i++)
+			if (is_nd_blk(&nd_region->dev))
+				namespace_blk_release(devs[i]);
+			else
+				namespace_pmem_release(devs[i]);
+		kfree(devs);
+	}
 	return NULL;
 }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] libnvdimm, namespace: potential NULL deref on allocation error
@ 2016-10-12  6:34 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-10-12  6:34 UTC (permalink / raw)
  To: Dan Williams
  Cc: linux-nvdimm-y27Ovi1pjclAfugRpC6u6w,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

If the kcalloc() fails then "devs" can be NULL and we dereference it
checking "devs[i]".

Fixes: 1b40e09a1232 ('libnvdimm: blk labels and namespace instantiation')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 3509cff..abe5c6b 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2176,12 +2176,14 @@ static struct device **scan_labels(struct nd_region *nd_region)
 	return devs;
 
  err:
-	for (i = 0; devs[i]; i++)
-		if (is_nd_blk(&nd_region->dev))
-			namespace_blk_release(devs[i]);
-		else
-			namespace_pmem_release(devs[i]);
-	kfree(devs);
+	if (devs) {
+		for (i = 0; devs[i]; i++)
+			if (is_nd_blk(&nd_region->dev))
+				namespace_blk_release(devs[i]);
+			else
+				namespace_pmem_release(devs[i]);
+		kfree(devs);
+	}
 	return NULL;
 }
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] libnvdimm, namespace: potential NULL deref on allocation error
  2016-10-12  6:34 ` Dan Carpenter
@ 2016-10-12 21:51   ` Dan Williams
  -1 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2016-10-12 21:51 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-nvdimm, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 11, 2016 at 11:34 PM, Dan Carpenter
<dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> wrote:
> If the kcalloc() fails then "devs" can be NULL and we dereference it
> checking "devs[i]".
>
> Fixes: 1b40e09a1232 ('libnvdimm: blk labels and namespace instantiation')
> Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Thanks, applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] libnvdimm, namespace: potential NULL deref on allocation error
@ 2016-10-12 21:51   ` Dan Williams
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2016-10-12 21:51 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-nvdimm, kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 11, 2016 at 11:34 PM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:
> If the kcalloc() fails then "devs" can be NULL and we dereference it
> checking "devs[i]".
>
> Fixes: 1b40e09a1232 ('libnvdimm: blk labels and namespace instantiation')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-12 21:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12  6:34 [patch] libnvdimm, namespace: potential NULL deref on allocation error Dan Carpenter
2016-10-12  6:34 ` Dan Carpenter
2016-10-12 21:51 ` Dan Williams
2016-10-12 21:51   ` Dan Williams

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.