summaryrefslogtreecommitdiff
path: root/drivers/staging/ft1000
diff options
context:
space:
mode:
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>2014-12-29 13:41:33 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-17 15:22:31 -0800
commit64ed8f51f97304f811f34e89afdccf7bf9836a93 (patch)
tree001efd2daa1db5b9e718dff6779530390b142f4f /drivers/staging/ft1000
parent0a5470f80ce7731160bbf8173e9df1ebeeb7e9e6 (diff)
staging: ft1000: ft1000-usb: ft1000_hw.c: Fix a potential memory leak.
Avoid allocate memory if we will exit the function. Was found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/ft1000')
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_hw.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
index d12cfc9aa32a..f0ac43838461 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
@@ -332,15 +332,15 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer,
pr_debug("enter card_send_command... size=%d\n", size);
+ ret = ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL);
+ if (ret)
+ return ret;
+
commandbuf = kmalloc(size + 2, GFP_KERNEL);
if (!commandbuf)
return -ENOMEM;
memcpy((void *)commandbuf + 2, (void *)ptempbuffer, size);
- ret = ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL);
- if (ret)
- return ret;
-
if (temp & 0x0100)
usleep_range(900, 1100);