Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751199AbdFCPgh (ORCPT ); Sat, 3 Jun 2017 11:36:37 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:34017 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbdFCPgf (ORCPT ); Sat, 3 Jun 2017 11:36:35 -0400 MIME-Version: 1.0 In-Reply-To: <1496442569-11307-1-git-send-email-housel@acm.org> References: <1496442569-11307-1-git-send-email-housel@acm.org> From: Andy Shevchenko Date: Sat, 3 Jun 2017 18:36:34 +0300 Message-ID: Subject: Re: [PATCH v2] brcmfmac: Fix glom_skb leak in brcmf_sdiod_recv_chain To: "Peter S. Housel" Cc: Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , Pieter-Paul Giesberts , Christian Daudt , Florian Fainelli , Florian Westphal , Martin Blumenstingl , "open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER" , "open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER" , "open list:NETWORKING DRIVERS" , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1522 Lines: 42 On Sat, Jun 3, 2017 at 1:29 AM, Peter S. Housel wrote: > An earlier change to this function (3bdae810721b) fixed a leak in the > case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the > glom_skb buffer, used for emulating a scattering read, is never used > or referenced after its contents are copied into the destination > buffers, and therefore always needs to be freed by the end of the > function. > err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr, > glom_skb); > - if (err) { > - brcmu_pkt_buf_free_skb(glom_skb); > - goto done; > - } > - > - skb_queue_walk(pktq, skb) { > - memcpy(skb->data, glom_skb->data, skb->len); > - skb_pull(glom_skb, skb->len); > + if (!err) { This is not so often in use type of pattern. > + 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); Can we just add this one line instead or I'm missing something? > } else > err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr, > pktq); -- With Best Regards, Andy Shevchenko