Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1343576 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2016-02-26 00:30 +0100 |
| Last post | 2016-02-26 00:50 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH][V3] mt7601u: do not free dma_buf when ivp allocation fails Colin King <colin.king@canonical.com> - 2016-02-26 00:30 +0100
Re: [PATCH][V3] mt7601u: do not free dma_buf when ivp allocation fails Julian Calaby <julian.calaby@gmail.com> - 2016-02-26 00:40 +0100
Re: [PATCH][V3] mt7601u: do not free dma_buf when ivp allocation fails Kuba Kicinski <kubakici@wp.pl> - 2016-02-26 00:50 +0100
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2016-02-26 00:30 +0100 |
| Subject | [PATCH][V3] mt7601u: do not free dma_buf when ivp allocation fails |
| Message-ID | <r6dw5-2Lc-7@gated-at.bofh.it> |
From: Colin Ian King <colin.king@canonical.com>
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>
---
drivers/net/wireless/mediatek/mt7601u/mcu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt7601u/mcu.c b/drivers/net/wireless/mediatek/mt7601u/mcu.c
index fbb1986..91c4b34 100644
--- a/drivers/net/wireless/mediatek/mt7601u/mcu.c
+++ b/drivers/net/wireless/mediatek/mt7601u/mcu.c
@@ -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;
}
--
2.7.0
[toc] | [next] | [standalone]
| From | Julian Calaby <julian.calaby@gmail.com> |
|---|---|
| Date | 2016-02-26 00:40 +0100 |
| Message-ID | <r6dFM-2OI-3@gated-at.bofh.it> |
| In reply to | #1343576 |
Hi,
On Fri, Feb 26, 2016 at 10:24 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
Looks right to me.
Reviewed-by: Julian Calaby <julian.calaby@gmail.com>
> ---
> drivers/net/wireless/mediatek/mt7601u/mcu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt7601u/mcu.c b/drivers/net/wireless/mediatek/mt7601u/mcu.c
> index fbb1986..91c4b34 100644
> --- a/drivers/net/wireless/mediatek/mt7601u/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt7601u/mcu.c
> @@ -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;
> }
> --
> 2.7.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
--
Julian Calaby
Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
[toc] | [prev] | [next] | [standalone]
| From | Kuba Kicinski <kubakici@wp.pl> |
|---|---|
| Date | 2016-02-26 00:50 +0100 |
| Message-ID | <r6dPs-2Ti-13@gated-at.bofh.it> |
| In reply to | #1343576 |
On 25 February 2016 18:24:27 GMT-05:00, Colin King <colin.king@canonical.com> wrote: >From: Colin Ian King <colin.king@canonical.com> > >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> LGTM, thanks.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web