mt7601u: do not free dma_buf when ivp allocation fails
authorColin Ian King <colin.king@canonical.com>
Thu, 25 Feb 2016 23:24:27 +0000 (23:24 +0000)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 7 Mar 2016 12:39:05 +0000 (14:39 +0200)
If the allocation of ivp fails the error handling attempts to
free an uninitialized dma_buf; this data structure just contains
garbage on the stack, so the freeing will cause issues when the
urb, buf and dma fields are free'd. Fix this by not free'ing the
dma_buf if the ivp allocation fails.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Julian Calaby <julian.calaby@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mediatek/mt7601u/mcu.c

index fbb1986eda3cb4eada8181979b157d7c88fe1b8b..91c4b34279657659dfbf2cdce58084b8517ea4f6 100644 (file)
@@ -362,7 +362,9 @@ mt7601u_upload_firmware(struct mt7601u_dev *dev, const struct mt76_fw *fw)
        int i, ret;
 
        ivb = kmemdup(fw->ivb, sizeof(fw->ivb), GFP_KERNEL);
-       if (!ivb || mt7601u_usb_alloc_buf(dev, MCU_FW_URB_SIZE, &dma_buf)) {
+       if (!ivb)
+               return -ENOMEM;
+       if (mt7601u_usb_alloc_buf(dev, MCU_FW_URB_SIZE, &dma_buf)) {
                ret = -ENOMEM;
                goto error;
        }
This page took 0.030951 seconds and 5 git commands to generate.