提交 5959809d 编写于 作者: J Julia Lawall 提交者: Marcel Holtmann

Bluetooth: Add missing kmalloc NULL tests to Marvell driver

Check that the result of kmalloc is not NULL before dereferencing it.
The patch also replaces kmalloc + memset by kzalloc.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *x;
identifier f;
constant char *C;
@@

x = \(kmalloc\|kcalloc\|kzalloc\)(...);
... when != x == NULL
    when != x != NULL
    when != (x || ...)
(
kfree(x)
|
f(...,C,...,x,...)
|
*f(...,x,...)
|
*x->f
)
// </smpl>
Signed-off-by: NJulia Lawall <julia@diku.dk>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 3318b236
...@@ -777,8 +777,9 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv, ...@@ -777,8 +777,9 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv,
buf = payload; buf = payload;
if ((unsigned long) payload & (BTSDIO_DMA_ALIGN - 1)) { if ((unsigned long) payload & (BTSDIO_DMA_ALIGN - 1)) {
tmpbufsz = ALIGN_SZ(nb, BTSDIO_DMA_ALIGN); tmpbufsz = ALIGN_SZ(nb, BTSDIO_DMA_ALIGN);
tmpbuf = kmalloc(tmpbufsz, GFP_KERNEL); tmpbuf = kzalloc(tmpbufsz, GFP_KERNEL);
memset(tmpbuf, 0, tmpbufsz); if (!tmpbuf)
return -ENOMEM;
buf = (u8 *) ALIGN_ADDR(tmpbuf, BTSDIO_DMA_ALIGN); buf = (u8 *) ALIGN_ADDR(tmpbuf, BTSDIO_DMA_ALIGN);
memcpy(buf, payload, nb); memcpy(buf, payload, nb);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册