Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1682778 > unrolled thread
| Started by | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| First post | 2017-07-07 00:40 +0200 |
| Last post | 2017-07-17 22:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] mtd: spear_smi: add NULL check on devm_kzalloc() return value "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-07-07 00:40 +0200
Re: [PATCH] mtd: spear_smi: add NULL check on devm_kzalloc() return value Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-07-17 22:50 +0200
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-07-07 00:40 +0200 |
| Subject | [PATCH] mtd: spear_smi: add NULL check on devm_kzalloc() return value |
| Message-ID | <u0nBg-3lx-25@gated-at.bofh.it> |
Check return value from call to devm_kzalloc()
in order to prevent a NULL pointer dereference.
This issue was detected using Coccinelle and the following semantic patch:
@@
expression x;
identifier fld;
@@
* x = devm_kzalloc(...);
... when != x == NULL
x->fld
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
drivers/mtd/devices/spear_smi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index dd50698..ddf4789 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -775,6 +775,8 @@ static int spear_smi_probe_config_dt(struct platform_device *pdev,
pdata->board_flash_info = devm_kzalloc(&pdev->dev,
sizeof(*pdata->board_flash_info),
GFP_KERNEL);
+ if (!pdata->board_flash_info)
+ return -ENOMEM;
/* Fill structs for each subnode (flash device) */
while ((pp = of_get_next_child(np, pp))) {
--
2.5.0
[toc] | [next] | [standalone]
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Date | 2017-07-17 22:50 +0200 |
| Subject | Re: [PATCH] mtd: spear_smi: add NULL check on devm_kzalloc() return value |
| Message-ID | <u4l7P-1qg-9@gated-at.bofh.it> |
| In reply to | #1682778 |
Le Thu, 6 Jul 2017 17:25:50 -0500,
"Gustavo A. R. Silva" <garsilva@embeddedor.com> a écrit :
> Check return value from call to devm_kzalloc()
> in order to prevent a NULL pointer dereference.
>
> This issue was detected using Coccinelle and the following semantic patch:
>
> @@
> expression x;
> identifier fld;
> @@
>
> * x = devm_kzalloc(...);
> ... when != x == NULL
> x->fld
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/mtd/devices/spear_smi.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
> index dd50698..ddf4789 100644
> --- a/drivers/mtd/devices/spear_smi.c
> +++ b/drivers/mtd/devices/spear_smi.c
> @@ -775,6 +775,8 @@ static int spear_smi_probe_config_dt(struct platform_device *pdev,
> pdata->board_flash_info = devm_kzalloc(&pdev->dev,
> sizeof(*pdata->board_flash_info),
> GFP_KERNEL);
> + if (!pdata->board_flash_info)
> + return -ENOMEM;
>
> /* Fill structs for each subnode (flash device) */
> while ((pp = of_get_next_child(np, pp))) {
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web