Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp956725rwb; Thu, 8 Dec 2022 05:13:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ZaEE8FX8b+Dmm6gjuF2LHtQkkLHtcvXvXKKQZTBkqezpkwCa7Tym/SZPkP9GGJ13WEv3R X-Received: by 2002:a05:6402:1103:b0:46a:779:4c6a with SMTP id u3-20020a056402110300b0046a07794c6amr63401722edv.201.1670505211966; Thu, 08 Dec 2022 05:13:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670505211; cv=none; d=google.com; s=arc-20160816; b=sbFOV5GA4BQUMBCisMWmeEELXDF2Zat2D4buC5i+N9H4TedPrVZIjh3/mLX0LNza4W ca03tZB2Zy0BDBdCyzf41Js+Q/dHvy1YasjiflcFf76xT17LX01LOWWqMts9F9xZBOAl /vjpkgPMkDAv+MM/RkzK7hjiG9m6SmbNDoIOA0QNCtGq7K1AHSMcX7c1UcyBvaaXYaVW LEXLx/94CPySda9MDzxJgUY+EKOQ+cCJqnS+DMdIz6IjcB8z26AX/TUlQlZCiXxR6bh1 5QEeDhHnDjeP4+2s0ls4F82ELFcEVcJj4VxFFOkjKCiSfSWySM15d2R++UpPxgcFNdyM EOPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7OO2KHG058YoZvm8oeczbxoH51PktZ4F404Z0YI0wUY=; b=DjUFNKHdN6Wc4F3Wh6FjWdnktwqWBk9lMPvmslPKespmiLaiN35PaO1zD8OG5kg/3L XIasZWVNznjjj/V1MKDjOWaet6UONOXm9qYDd5r6zCKRbEbYTymD8vpKpaaUHt7gsBkl up/z00n4xkZF9rFDII0igoKcQrfTTjlzmhBB7fK8Mpr79d0+HF3cIwjus0bXAeU0sEsu zCzxdO5CJZNsezMMyD+YLC0bGbZaH0JLXEVLOdJ92xRkW3XsH0hhgu8aEYZlSOO5wtTT SA7t4YcXwBNdCINcpvbCgaQOGiivfIPSjUpzvAJaOFGoM/LXcjDxz8mW3RyajLtu6iVR /KQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20210112.gappssmtp.com header.s=20210112 header.b=t79L3CEA; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a056402268900b0045bdff8a884si7722244edd.268.2022.12.08.05.13.08; Thu, 08 Dec 2022 05:13:31 -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=@resnulli-us.20210112.gappssmtp.com header.s=20210112 header.b=t79L3CEA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbiLHNAy (ORCPT + 65 others); Thu, 8 Dec 2022 08:00:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbiLHNAx (ORCPT ); Thu, 8 Dec 2022 08:00:53 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D6F08C69E for ; Thu, 8 Dec 2022 05:00:52 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id kw15so3615312ejc.10 for ; Thu, 08 Dec 2022 05:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7OO2KHG058YoZvm8oeczbxoH51PktZ4F404Z0YI0wUY=; b=t79L3CEApL9wxNlXQmkcXk2pHUfIutULCchChTrDm9E94pbFKC04l2QldTYJv8gMDw zcj8AUNg04g73kdlc8pvDbfzNsv4Wfrz1yB1kig0QwEISwHVWisvHv+MZSXPoNycSWYZ /a6LmbEgeh0Gbeargnv4hBSejl4KkeRdKKmMPQhij2Ag9hS10DCamUcQHmH4s2qI7/qR 5K1oJvW0YqH42yUigl/7Vy3KF4GbXJD6oDoi+NuTJ2og814PGu8Lk9mMldrkQvHA7iR/ PrpvDgAij5qmvGyklTWdFFzgXpsmizvmC8hUdtW5s8pKc/UeuAyIRopB+LgFY7zWMIzp 2Wwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7OO2KHG058YoZvm8oeczbxoH51PktZ4F404Z0YI0wUY=; b=tQvqIvQK70N0sBb3X2Qg5h9L6UdO58BslSNxvIPJrN+bnO5YvTN6gzMHdiPP5tmsq8 D8OluqMhp/Vi56bp9D1SCeFsbCV9Uz9oGnW8cJrUHyLTlIrWYFhaQj3Hb/IMuEbTe+I5 lW4BB2kzFDDPcSMZvHXzYutoUHEU9yA53kSL/c6VjDt8CK3+CHoR8QGL3bScKb9VZ2ke kwgCTighteQMs/cZ9aXuoxZLR6xvOFeHg5dOWFUQmQcU7C8dd6OK4j0FO8sekPNxU775 fL5t9hOK0tDizPx3/xpkN+HefD1r/aJqBVMAmbn5dhp8fnR7xxN8QVohcXhlEMcaebQT eMNg== X-Gm-Message-State: ANoB5pltuOKcmoPfCna6Q2Bevu++M5IVoCHpgLszxD6efjgpnfavyUTE IaPIEjW0wKRk+oqCudLSdIc9RA== X-Received: by 2002:a17:906:bcf3:b0:7c1:22a6:818c with SMTP id op19-20020a170906bcf300b007c122a6818cmr1302416ejb.46.1670504450560; Thu, 08 Dec 2022 05:00:50 -0800 (PST) Received: from localhost (host-213-179-129-39.customer.m-online.net. [213.179.129.39]) by smtp.gmail.com with ESMTPSA id l1-20020a1709060cc100b00779cde476e4sm9697495ejh.62.2022.12.08.05.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 05:00:49 -0800 (PST) Date: Thu, 8 Dec 2022 14:00:48 +0100 From: Jiri Pirko To: Zhengchao Shao Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, stas.yakovlev@gmail.com, kvalo@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linville@tuxdriver.com, weiyongjun1@huawei.com, yuehaibing@huawei.com Subject: Re: [PATCH] ipw2200: fix memory leak in ipw_wdev_init() Message-ID: References: <20221208122630.2850534-1-shaozhengchao@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221208122630.2850534-1-shaozhengchao@huawei.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE 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 Thu, Dec 08, 2022 at 01:26:30PM CET, shaozhengchao@huawei.com wrote: >In the error path of ipw_wdev_init(), exception value is returned, and >the memory applied for in the function is not released. Also the memory >is not released in ipw_pci_probe(). As a result, memory leakage occurs. >So memory release needs to be added to the error path of ipw_wdev_init(). > >Fixes: a3caa99e6c68 ("libipw: initiate cfg80211 API conversion (v2)") >Signed-off-by: Zhengchao Shao >--- > drivers/net/wireless/intel/ipw2x00/ipw2200.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > >diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c >index 5b483de18c81..cead5c7fc91e 100644 >--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c >+++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c >@@ -11397,9 +11397,15 @@ static int ipw_wdev_init(struct net_device *dev) > set_wiphy_dev(wdev->wiphy, &priv->pci_dev->dev); > > /* With that information in place, we can now register the wiphy... */ >- if (wiphy_register(wdev->wiphy)) >+ if (wiphy_register(wdev->wiphy)) { While you are at it, how about to take the actual return value of wiphy_register() into account? > rc = -EIO; >+ goto out; >+ } >+ >+ return 0; > out: >+ kfree(priv->ieee->a_band.channels); >+ kfree(priv->ieee->bg_band.channels); > return rc; > } > >-- >2.34.1 >