[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s |
Date: |
Tue, 8 Mar 2016 13:21:52 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
On 08/03/2016 08:00, Peter Xu wrote:
> First of all, this function cannot be inlined even with always_inline,
> so removing inline.
Why? always_inline fixes the error for me.
> int i;
> - uint32_t tmp[len / sizeof(uint32_t)];
> + uint32_t n = len / sizeof(uint32_t);
> +#define __BUF_SIZE (12)
> + uint32_t tmp[__BUF_SIZE];
>
> + assert(__BUF_SIZE >= n);
Instead of a #define, you can use ARRAY_SIZE(tmp).
Paolo
> assert((len % sizeof(uint32_t)) == 0);
>
> - for (i = 0; i < (len / sizeof(uint32_t)); i++) {
> + for (i = 0; i < n; i++) {
> tmp[i] = cpu_to_le32(buf[i]);
> }
> pci_dma_write(PCI_DEVICE(xhci), addr, tmp, len);
> +#undef __BUF_SIZE
> }
>
> static XHCIPort *xhci_lookup_port(XHCIState *xhci, struct USBPort *uport)
>
[Qemu-devel] [PATCH 3/8] usb: fix unbounded stack for ohci_td_pkt, Peter Xu, 2016/03/08
[Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Peter Xu, 2016/03/08
- Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Peter Maydell, 2016/03/08
- Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Peter Xu, 2016/03/09
- Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Paolo Bonzini, 2016/03/09
- Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Peter Xu, 2016/03/09
- Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Markus Armbruster, 2016/03/09
- Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Peter Xu, 2016/03/09
- Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Markus Armbruster, 2016/03/09
Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Paolo Bonzini, 2016/03/09
Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s, Peter Xu, 2016/03/09
[Qemu-devel] [PATCH 5/8] usb: fix unbounded stack for inotify_watchfn, Peter Xu, 2016/03/08