From patchwork Fri Jun 2 17:22:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peter S. Housel" X-Patchwork-Id: 9763099 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 805E160360 for ; Fri, 2 Jun 2017 17:37:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D0CE28546 for ; Fri, 2 Jun 2017 17:37:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E81728592; Fri, 2 Jun 2017 17:37:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF57328546 for ; Fri, 2 Jun 2017 17:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751212AbdFBRhs (ORCPT ); Fri, 2 Jun 2017 13:37:48 -0400 Received: from fed1rmfepi103.cox.net ([68.230.241.134]:56245 "EHLO fed1rmfepi103.cox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751154AbdFBRhs (ORCPT ); Fri, 2 Jun 2017 13:37:48 -0400 X-Greylist: delayed 554 seconds by postgrey-1.27 at vger.kernel.org; Fri, 02 Jun 2017 13:37:47 EDT Received: from fed1rmimpo110.cox.net ([68.230.241.159]) by fed1rmfepo102.cox.net (InterMail vM.8.01.05.28 201-2260-151-171-20160122) with ESMTP id <20170602172832.FKNF32620.fed1rmfepo102.cox.net@fed1rmimpo110.cox.net> for ; Fri, 2 Jun 2017 13:28:32 -0400 Received: from expanse-fc64.housel.dyndns.org ([70.187.180.87]) by fed1rmimpo110.cox.net with cox id TtUY1v00N1tYKWE01tUY9c; Fri, 02 Jun 2017 13:28:32 -0400 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A090203.5931A040.00B2, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.1 cv=ZPF34SPb c=1 sm=1 tr=0 a=2h5joy4Vliq9J2KtwSbkFg==:117 a=2h5joy4Vliq9J2KtwSbkFg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=yEt_ySCYCeAA:10 a=LWSFodeU3zMA:10 a=N54-gffFAAAA:8 a=3T-nJzyC3FGPieS7n5sA:9 a=6l0D2HzqY3Epnrm8mE3f:22 X-CM-Score: 0.00 Authentication-Results: cox.net; none Received: from expanse-ux64.housel.dyndns.org (expanse-ux64.housel.dyndns.org [10.0.0.160]) by expanse-fc64.housel.dyndns.org (8.15.2/8.15.2) with ESMTP id v52HSVC0078224; Fri, 2 Jun 2017 10:28:31 -0700 (PDT) (envelope-from housel@acm.org) From: "Peter S. Housel" To: Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , Christian Daudt , Pieter-Paul Giesberts , Martin Blumenstingl , Florian Fainelli , "Peter S. Housel" , linux-wireless@vger.kernel.org (open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER), brcm80211-dev-list.pdl@broadcom.com (open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER), netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain Date: Fri, 2 Jun 2017 10:22:21 -0700 Message-Id: <1496424146-10928-1-git-send-email-housel@acm.org> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP An earlier change to this function (3bdae810721b) fixed a leak in the case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the glob_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. Signed-off-by: Peter S. Housel --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c index 9b970dc..4c5064f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c @@ -727,15 +727,16 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev, return -ENOMEM; err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr, glom_skb); - if (err) { - brcmu_pkt_buf_free_skb(glom_skb); - goto done; - } + if (err) + goto free_glom_skb; skb_queue_walk(pktq, skb) { memcpy(skb->data, glom_skb->data, skb->len); skb_pull(glom_skb, skb->len); } + +free_glom_skb: + brcmu_pkt_buf_free_skb(glom_skb); } else err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr, pktq);