Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1720752 > unrolled thread
| Started by | Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
|---|---|
| First post | 2017-08-27 08:40 +0200 |
| Last post | 2017-08-30 01:00 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] libnvdimm, btt: check memory allocation failure Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-08-27 08:40 +0200
Re: [PATCH] libnvdimm, btt: check memory allocation failure Vishal Verma <vishal.l.verma@intel.com> - 2017-08-30 01:00 +0200
| From | Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
|---|---|
| Date | 2017-08-27 08:40 +0200 |
| Subject | [PATCH] libnvdimm, btt: check memory allocation failure |
| Message-ID | <uiZoJ-3VU-1@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Vishal Verma <vishal.l.verma@intel.com> |
|---|---|
| Date | 2017-08-30 01:00 +0200 |
| Message-ID | <ujXEd-bG-7@gated-at.bofh.it> |
| In reply to | #1720752 |
On 08/27, Christophe JAILLET wrote:
> 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(+)
Looks good, thank you.
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
>
> 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
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web