mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] libnvdimm: fix dereference on null devs on error exit path
@ 2016-10-15 15:32 Colin King
  2016-10-15 15:49 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2016-10-15 15:32 UTC (permalink / raw)
  To: Dan Williams, linux-nvdimm; +Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

If devs cannot be allocated then the error exit path jumps to
a cleanup loop that iterates over a null array of devs which
is incorrect.  Fix this by jumping instead to the end of the
function where NULL is returned.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/nvdimm/namespace_devs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 3509cff..5d2755a 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2125,7 +2125,7 @@ static struct device **scan_labels(struct nd_region *nd_region)
 
 		devs = kcalloc(2, sizeof(dev), GFP_KERNEL);
 		if (!devs)
-			goto err;
+			goto err_ret;
 		if (is_nd_blk(&nd_region->dev)) {
 			struct nd_namespace_blk *nsblk;
 
@@ -2182,6 +2182,7 @@ static struct device **scan_labels(struct nd_region *nd_region)
 		else
 			namespace_pmem_release(devs[i]);
 	kfree(devs);
+ err_ret:
 	return NULL;
 }
 
-- 
2.9.3

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

* Re: [PATCH] libnvdimm: fix dereference on null devs on error exit path
  2016-10-15 15:32 [PATCH] libnvdimm: fix dereference on null devs on error exit path Colin King
@ 2016-10-15 15:49 ` Dan Williams
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2016-10-15 15:49 UTC (permalink / raw)
  To: Colin King; +Cc: linux-nvdimm@lists.01.org, linux-kernel

On Sat, Oct 15, 2016 at 8:32 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> If devs cannot be allocated then the error exit path jumps to
> a cleanup loop that iterates over a null array of devs which
> is incorrect.  Fix this by jumping instead to the end of the
> function where NULL is returned.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks, I've already applied a similar fix from Dan Carpenter.

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

end of thread, other threads:[~2016-10-15 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-15 15:32 [PATCH] libnvdimm: fix dereference on null devs on error exit path Colin King
2016-10-15 15:49 ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®