Message ID | 1450610153-7746-2-git-send-email-Julia.Lawall@lip6.fr (mailing list archive) |
---|---|
State | Accepted |
Commit | 10974ccf04b096fd79ad90fd50276b79c069f2cc |
Headers | show |
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; >
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;
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(+)