Commit 64ed8f51 authored by Rickard Strandqvist's avatar Rickard Strandqvist Committed by Greg Kroah-Hartman

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: default avatarRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0a5470f8
...@@ -332,15 +332,15 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, ...@@ -332,15 +332,15 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer,
pr_debug("enter card_send_command... size=%d\n", size); 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); commandbuf = kmalloc(size + 2, GFP_KERNEL);
if (!commandbuf) if (!commandbuf)
return -ENOMEM; return -ENOMEM;
memcpy((void *)commandbuf + 2, (void *)ptempbuffer, size); memcpy((void *)commandbuf + 2, (void *)ptempbuffer, size);
ret = ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL);
if (ret)
return ret;
if (temp & 0x0100) if (temp & 0x0100)
usleep_range(900, 1100); usleep_range(900, 1100);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment