Re: [PATCH] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain

From: Andy Shevchenko
Date: Sat Jun 03 2017 - 11:46:29 EST


On Fri, Jun 2, 2017 at 9:52 PM, Franky Lin <franky.lin@xxxxxxxxxxxx> wrote:
> On Fri, Jun 2, 2017 at 10:22 AM, Peter S. Housel <housel@xxxxxxx> wrote:

>> err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
>> glom_skb);
>> - if (err) {
>> - brcmu_pkt_buf_free_skb(glom_skb);
>> - goto done;
>> - }

> What about
> if (!err) {
> skb_queue_walk(pktq, skb) {
> memcpy(skb->data, glom_skb->data, skb->len);
> skb_pull(glom_skb, skb->len);
> }
> }
> brcmu_pkt_buf_free_skb(glom_skb);
>
> Then no goto is needed.

For my point of view it has two subtle inconveniences:
1. Not so usual pattern in use if (!ret)
2. Less error prone in case someone decides to expand the code and
missed ! or something else there.

Since both makes an approach less error prone I wouldn't suggest doing
that as I commented in new version.

--
With Best Regards,
Andy Shevchenko