mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] libnvdimm, btt: check memory allocation failure
@ 2017-08-27  6:30 Christophe JAILLET
  2017-08-29 22:50 ` Vishal Verma
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2017-08-27  6:30 UTC (permalink / raw)
  To: dan.j.williams, vishal.l.verma
  Cc: linux-nvdimm, linux-kernel, kernel-janitors, Christophe JAILLET

Check memory allocation failures and return -ENOMEM in such cases, as
already done few lines below for another memory allocation.

This avoids NULL pointers dereference.

Fixes: 14e494542636 ("libnvdimm, btt: BTT updates for UEFI 2.7 format")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/nvdimm/btt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 60491641a8d6..607184ebcfbf 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1431,6 +1431,8 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns)
 	}
 
 	btt_sb = devm_kzalloc(&nd_btt->dev, sizeof(*btt_sb), GFP_KERNEL);
+	if (!btt_sb)
+		return -ENOMEM;
 
 	/*
 	 * If this returns < 0, that is ok as it just means there wasn't
-- 
2.11.0

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

end of thread, other threads:[~2017-08-29 22:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-27  6:30 [PATCH] libnvdimm, btt: check memory allocation failure Christophe JAILLET
2017-08-29 22:50 ` Vishal Verma

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®