* [PATCH 0/4] add NULL test
@ 2015-12-20 11:15 Julia Lawall
2015-12-20 11:15 ` [PATCH 1/4] ASoC: imx-pcm-dma: " Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2015-12-20 11:15 UTC (permalink / raw)
To: linux-s390
Cc: kernel-janitors, linuxppc-dev, alsa-devel, linux-kernel,
linux-omap
Add NULL tests on various calls to kzalloc and devm_kzalloc.
The semantic match that finds these problems is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression x,y;
identifier fld;
@@
(
x = \(vmalloc\|kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|krealloc\|
kmemdup\|kstrdup\|
devm_kzalloc\|devm_kmalloc\|devm_kcalloc\|devm_kasprintf\|
kmalloc_array\)(...,<+... __GFP_NOFAIL ...+>,...);
|
* x = \(vmalloc\|kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|krealloc\|
kmemdup\|kstrdup\|
devm_kzalloc\|devm_kmalloc\|devm_kcalloc\|devm_kasprintf\|
kmalloc_array\)(...);
)
... when != (x) == NULL
when != (x) != NULL
when != (x) == 0
when != (x) != 0
when != x = y
(
x->fld
|
*x
|
x[...]
)
// </smpl>
---
drivers/s390/char/con3215.c | 2 ++
drivers/s390/char/raw3270.c | 2 ++
sound/soc/fsl/imx-pcm-dma.c | 2 ++
sound/soc/intel/baytrail/sst-baytrail-pcm.c | 2 ++
sound/soc/omap/omap-hdmi-audio.c | 2 ++
5 files changed, 10 insertions(+)
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 1/4] ASoC: imx-pcm-dma: add NULL test
2015-12-20 11:15 [PATCH 0/4] add NULL test Julia Lawall
@ 2015-12-20 11:15 ` Julia Lawall
2015-12-21 7:34 ` Nicolin Chen
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2015-12-20 11:15 UTC (permalink / raw)
To: Timur Tabi
Cc: kernel-janitors, Nicolin Chen, Xiubo Li, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
linuxppc-dev, linux-kernel
Add NULL test on call to devm_kzalloc.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression x;
@@
* x = devm_kzalloc(...);
... when != x == NULL
*x
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
sound/soc/fsl/imx-pcm-dma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c
index 1fc01ed..f3d3d1f 100644
--- a/sound/soc/fsl/imx-pcm-dma.c
+++ b/sound/soc/fsl/imx-pcm-dma.c
@@ -62,6 +62,8 @@ int imx_pcm_dma_init(struct platform_device *pdev, size_t size)
config = devm_kzalloc(&pdev->dev,
sizeof(struct snd_dmaengine_pcm_config), GFP_KERNEL);
+ if (!config)
+ return -ENOMEM;
*config = imx_dmaengine_pcm_config;
if (size)
config->prealloc_buffer_size = size;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/4] ASoC: imx-pcm-dma: add NULL test
2015-12-20 11:15 ` [PATCH 1/4] ASoC: imx-pcm-dma: " Julia Lawall
@ 2015-12-21 7:34 ` Nicolin Chen
0 siblings, 0 replies; 3+ messages in thread
From: Nicolin Chen @ 2015-12-21 7:34 UTC (permalink / raw)
To: Julia Lawall
Cc: Timur Tabi, kernel-janitors, Xiubo Li, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linuxppc-dev,
linux-kernel
On Sun, Dec 20, 2015 at 12:15:50PM +0100, Julia Lawall wrote:
> Add NULL test on call to devm_kzalloc.
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression x;
> @@
>
> * x = devm_kzalloc(...);
> ... when != x == NULL
> *x
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Thank you
>
> ---
> sound/soc/fsl/imx-pcm-dma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c
> index 1fc01ed..f3d3d1f 100644
> --- a/sound/soc/fsl/imx-pcm-dma.c
> +++ b/sound/soc/fsl/imx-pcm-dma.c
> @@ -62,6 +62,8 @@ int imx_pcm_dma_init(struct platform_device *pdev, size_t size)
>
> config = devm_kzalloc(&pdev->dev,
> sizeof(struct snd_dmaengine_pcm_config), GFP_KERNEL);
> + if (!config)
> + return -ENOMEM;
> *config = imx_dmaengine_pcm_config;
> if (size)
> config->prealloc_buffer_size = size;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-21 7:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-20 11:15 [PATCH 0/4] add NULL test Julia Lawall
2015-12-20 11:15 ` [PATCH 1/4] ASoC: imx-pcm-dma: " Julia Lawall
2015-12-21 7:34 ` Nicolin Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox