Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp316831rwj; Thu, 22 Dec 2022 08:06:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXtjMUuI0dq/XPf73XuoFQBPocYxfFcCVYO/xi4lXVhYYF9Je/ZxVlKhGgK44ipenNzauYNc X-Received: by 2002:a17:902:c94f:b0:189:9e91:762e with SMTP id i15-20020a170902c94f00b001899e91762emr10077067pla.57.1671725180537; Thu, 22 Dec 2022 08:06:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671725180; cv=none; d=google.com; s=arc-20160816; b=pl6P7/w/FRTEQa8ZAjz91bJPHclK6tmkgL9cwcbD0HenzxvGGRoXYV5w/lGwb+mZq9 BMTCJMIWze6HanuF8JCU2NYFB201ESacxoM5b02Mbi9511Yk1bH2TJ0SvklsTFr8zsrJ WrlVKyQoUDZ2Ss7wwoRHSm4emxfqcMXu19NO1b0ziK2JhXJj3mPCO5eDRbtbE0VgiabI OyT+P1Lyl24t/9mFvjPHMfCJWYGtOuElU/ibJxBm280srRFJNK0SjCuoJecQwIZoE5yH 42wgUZxyU6JjHNhY3D/xM2CKnaaR/oMbiJCDu0do2gPKuEBinP5me+z7I7dzEdWzNTFH YmSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=YUwWKozu8VMMI7F6uLl68tXvvPPJx1NALWyuRdQpLLw=; b=J/ilZ87dmRMBZTjWSOBI0AkIElNBazmyZVus/QRTC6XSYOAAWN8oqz0Idgq1RFh+7K pV0b86gURtodhdeRiQ7zGmQMN8bcyaht9QtNScLxJes7kYtKCDeJuIJ2fYcBV3y5mqXO sddP3G7tNPgtQKN9i+kat6Q+XRwiVifOnJmeS02pOCUyRaAVw0ugWUik6xcIEX82aN9t 52bmzBGAjTUSn2vaQcUWy42SJNqQO1ySjtku6zjOwlIGsc7uvefBndA7ipTSysusMDfs DrQxbfuirBWFMh0x/YR6f47CBeLQe5oT283FtD2EjMlUH86xBNrVjYoAKMV+Nc7hYQ4x YcQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mqfEIXW6; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170903018900b00189906d63bdsi1000866plg.7.2022.12.22.08.06.05; Thu, 22 Dec 2022 08:06:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mqfEIXW6; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231892AbiLVQB1 (ORCPT + 66 others); Thu, 22 Dec 2022 11:01:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbiLVQBZ (ORCPT ); Thu, 22 Dec 2022 11:01:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 890D1102A; Thu, 22 Dec 2022 08:01:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 27AA961C36; Thu, 22 Dec 2022 16:01:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BDDCC433D2; Thu, 22 Dec 2022 16:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671724883; bh=K2JjOPdLe6p7TeCT7N6YrUkgLNDqAeGFUTw14h5uQK8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=mqfEIXW6a7u+sj73dJ+oSBV1AUqaUIdHLjrV6jTf1hQECOWSbol3Grgp/SRqPm3Y/ K42/eYnHCGQXG5KEolf8GVyZOUZSDEudP1AcF4FtVdN3+pDDtEFR51e/j65ANg5xZC j6713OtEF6kB8JlCnmr1chvXMV6EXNcBnurhfw2fmpcQxjm+tK0jfUJJ2XQQi+RQof IgGBGM6GnobAnpKq3xDccbB0gwMaDv/4HwOHioQe58c8eLNga9mMEmVvSEt6fFrDYN KwGFkfKy3bI7Ke2+UlhRg7PeUdnoft/EuiB6HtEzmVRERA9xNIMnpWs8zKzGUZdEvJ ivgIGmO7E5BDw== From: Kalle Valo To: Jianglei Nie Cc: aspriel@gmail.com, franky.lin@broadcom.com, hante.meuleman@broadcom.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, alsi@bang-olufsen.dk, rmk+kernel@armlinux.org.uk, linus.walleij@linaro.org, marcan@marcan.st, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: brcmfmac: fix potential resource leak in brcmf_usb_probe_phase2() References: <20221120103807.7588-1-niejianglei2021@163.com> Date: Thu, 22 Dec 2022 18:01:17 +0200 In-Reply-To: <20221120103807.7588-1-niejianglei2021@163.com> (Jianglei Nie's message of "Sun, 20 Nov 2022 18:38:07 +0800") Message-ID: <874jtnjulu.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Jianglei Nie writes: > brcmf_usb_probe_phase2() allocates resource for dev with brcmf_alloc(). > The related resource should be released when the function gets some error. > But when brcmf_attach() fails, relevant resource is not released, which > will lead to resource leak. > > Fix it by calling brcmf_free() when brcmf_attach() fails. > > Signed-off-by: Jianglei Nie > --- > drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c > index 85e18fb9c497..5d8c12b2c4d7 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c > @@ -1215,6 +1215,7 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret, > return; > error: > brcmf_dbg(TRACE, "failed: dev=%s, err=%d\n", dev_name(dev), ret); > + brcmf_free(devinfo->dev); > complete(&devinfo->dev_init_done); > device_release_driver(dev); > } This doesn't look right. Now we would call brfmf_free() even before brcmf_alloc() is called. -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches