lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 9 Apr 2019 14:55:44 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Arend Van Spriel <arend.vanspriel@...adcom.com>
Cc:     Colin King <colin.king@...onical.com>,
        Franky Lin <franky.lin@...adcom.com>,
        Hante Meuleman <hante.meuleman@...adcom.com>,
        Chi-Hsien Lin <chi-hsien.lin@...ress.com>,
        Wright Feng <wright.feng@...ress.com>,
        Kalle Valo <kvalo@...eaurora.org>,
        "David S . Miller" <davem@...emloft.net>,
        linux-wireless@...r.kernel.org,
        brcm80211-dev-list.pdl@...adcom.com,
        brcm80211-dev-list@...ress.com, netdev@...r.kernel.org,
        kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][V2] brcmfmac: fix leak of mypkt on error return path

On Tue, Apr 09, 2019 at 01:50:38PM +0200, Arend Van Spriel wrote:
> On 4/9/2019 1:43 PM, Colin King wrote:
> > From: Colin Ian King <colin.king@...onical.com>
> > 
> > Currently if the call to brcmf_sdiod_set_backplane_window fails then
> > then error return path leaks mypkt. Fix this by returning by a new
> > error path labelled 'out' that calls brcmu_pkt_buf_free_skb to free
> > mypkt.  Also remove redundant check on err before calling
> > brcmf_sdiod_skbuff_write.
> > 
> > Addresses-Coverity: ("Resource Leak")
> > Fixes: a7c3aa1509e2 ("brcmfmac: Remove brcmf_sdiod_addrprep()")
> > Signed-off-by: Colin Ian King <colin.king@...onical.com>
> > ---
> > 
> > V2: Remove  redundant check on err before calling
> > brcmf_sdiod_skbuff_write, kudos to Dan Carpenter and Arend Van Spriel
> > for spotting this.
> > 
> > ---
> >   drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 8 +++-----
> >   1 file changed, 3 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> > index ec129864cc9c..60aede5abb4d 100644
> > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> > @@ -628,15 +628,13 @@ int brcmf_sdiod_send_buf(struct brcmf_sdio_dev *sdiodev, u8 *buf, uint nbytes)
> >   	err = brcmf_sdiod_set_backplane_window(sdiodev, addr);
> >   	if (err)
> > -		return err;
> > +		goto out;
> >   	addr &= SBSDIO_SB_OFT_ADDR_MASK;
> >   	addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
> > -	if (!err)
> > -		err = brcmf_sdiod_skbuff_write(sdiodev, sdiodev->func2, addr,
> > -					       mypkt);
> > -
> > +	err = brcmf_sdiod_skbuff_write(sdiodev, sdiodev->func2, addr, mypkt);
> > +out:
> 
> I am fine with it, but my suggestion was a bit different:
> 
> 	err = brcmf_sdiod_set_backplane_window(sdiodev, addr);
> 	if (!err) {
> 		addr &= SBSDIO_SB_OFT_ADDR_MASK;
> 		addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
> 		err = brcmf_sdiod_skbuff_write(sdiodev, sdiodev->func2,
> 					       addr, mypkt);
> 	}

Success handling always leads to extra indenting like this...  It's
less confusing to do failure handling keep the normal/success path at
indent level 1.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ