aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/btmrvl_sdio.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-08-06 16:05:18 -0400
committerMarcel Holtmann <marcel@holtmann.org>2009-08-22 17:33:22 -0400
commit5959809ded86e267c1a95fb44738a224c30d3434 (patch)
tree73cbd8c5a91c34d1df743dfc15d1cf954ed8d4fe /drivers/bluetooth/btmrvl_sdio.c
parent3318b2362bf0528be77123c480249663557dfbfc (diff)
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: Julia Lawall <julia@diku.dk> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth/btmrvl_sdio.c')
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 1cfa8b4ace50..5b33b85790f2 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -777,8 +777,9 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv,
777 buf = payload; 777 buf = payload;
778 if ((unsigned long) payload & (BTSDIO_DMA_ALIGN - 1)) { 778 if ((unsigned long) payload & (BTSDIO_DMA_ALIGN - 1)) {
779 tmpbufsz = ALIGN_SZ(nb, BTSDIO_DMA_ALIGN); 779 tmpbufsz = ALIGN_SZ(nb, BTSDIO_DMA_ALIGN);
780 tmpbuf = kmalloc(tmpbufsz, GFP_KERNEL); 780 tmpbuf = kzalloc(tmpbufsz, GFP_KERNEL);
781 memset(tmpbuf, 0, tmpbufsz); 781 if (!tmpbuf)
782 return -ENOMEM;
782 buf = (u8 *) ALIGN_ADDR(tmpbuf, BTSDIO_DMA_ALIGN); 783 buf = (u8 *) ALIGN_ADDR(tmpbuf, BTSDIO_DMA_ALIGN);
783 memcpy(buf, payload, nb); 784 memcpy(buf, payload, nb);
784 } 785 }