Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11632037rwl; Tue, 3 Jan 2023 02:16:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXvObGsjiKEuUhxNg32/ZCpiReybXktswmt2dLInIs81nch13f/pGfQ/S80Fo9p0dUUVsFX8 X-Received: by 2002:a05:6a00:21c6:b0:576:a74a:13c3 with SMTP id t6-20020a056a0021c600b00576a74a13c3mr56958595pfj.1.1672740990930; Tue, 03 Jan 2023 02:16:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672740990; cv=none; d=google.com; s=arc-20160816; b=FH/FLpda0QGyzdZZup+sQTRJSy2SjrL4nJAyTKliKNLLM3flIzivyS8X3LbXcjO1Eu S7rgHwCG9MqLCPkYFrizMAfqhDVet8LNY4uv7mmM69Pw45jVPJiRtKJA8bReaLtZSHYI 8OHsi3qbLpnWKJTUOM+9hXsccGen1PylytdAmMAzSwJsijaYHC0PeHgQ0T3+0DksyU9l 8vIjfLYk9MkfUAfLU2C4/xQNJsfBDVoc5OeBmDC+YCkpIHCjK2P30nfPjuihuEnIV6XL YMjrTlgXpN8lNRinKnvjrl8eDp6VOEvsj8/eo2ntjut1MaxRHWBD/Z6GPwIaNE+NudwD tBiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WyU2gotHiarMUYf0JzfryOmpJ2sWzgyn/HCYaB7+/Ik=; b=xW7a8ss9rxl6aiODvrAvc+LB6L1mmHlTgmvX+4lZqV2OnbKa/qSbu8v0ulDprVQfN5 vBGQsXKT+Ds8prw34u4mRQ6mLv4Kgv+1bBS6sYvcmTVRG1dHdRm/vX/P08X6t5K4jPK0 XvtwlGPEyNtYzL2GbyBI9uLdDj2P03tXODv8w82aLZRLf0I8oGvNdmUgx3l7YZziY8cZ nt4AkSVE8ePr0rz4Ijluwy2KlvOz02J72WkmwIl9McG+130xsY896Tou08wHp3Cw0KD1 507636L8qsI3F46qFtVV2Wui9V8UFgfgSu1z+Z72dDDoDIjBEjCil0arM4l3BrCBLf4d Bq9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VnNLO2ID; 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 e14-20020a056a001a8e00b0056d7aaaf1eesi32402869pfv.122.2023.01.03.02.16.21; Tue, 03 Jan 2023 02:16:30 -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=VnNLO2ID; 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 S237132AbjACKQU (ORCPT + 67 others); Tue, 3 Jan 2023 05:16:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237350AbjACKP7 (ORCPT ); Tue, 3 Jan 2023 05:15:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACD9FF6C for ; Tue, 3 Jan 2023 02:15:57 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6B492B80E64 for ; Tue, 3 Jan 2023 10:15:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7673C433D2; Tue, 3 Jan 2023 10:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672740955; bh=0Y3LOkAwBPu0GXmutmpHI22q7o0KKKn2e6onxQBoxYA=; h=From:To:Cc:Subject:Date:From; b=VnNLO2ID5SpLEjXovsf+Jt2mlYct9kn791zsK6AxtD4Mwr1rqxoJcgAl/0Ro4sC93 qNi4lEsQR+JtV2SROGJjdlFWMYJrAGZEQgYLLt3+qN2RTJcSawcW4T6MaYWEF1qKOa k9un8imu7R3ErAjo0pby6t5NgCFT7RRJWx00Nm3Dw6YzzZkq6W+YgEFnoGdboeA5Ad VgiT6LskHHrOiJoimpQMJpCXK5OcxK60uYsFOUF8pg449TZ5h2RbHrCJhxcilwl5Vi cxk83NAv4VdeEHHma+xlUCZXIjLU6HopBxpX54lMNZszppqYMFq1gJxUaYf6jK7ao6 /VUE/IBFsQRTA== From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH] wifi: mt76: mt7915: fix memory leak in mt7915_rate_txpower_get Date: Tue, 3 Jan 2023 11:15:49 +0100 Message-Id: <2ea534ec17856f65237939f3d437aad37ddc7753.1672740921.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Fix possible memory leak in mt7915_rate_txpower_get routine if mt7915_mcu_get_txpower_sku() fails. Fixes: e3296759f347 ("wifi: mt76: mt7915: enable per bandwidth power limit support") Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index fb46c2c1784f..4730508652af 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -990,14 +990,14 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf, char *buf; u32 reg; - buf = kzalloc(sz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - ret = mt7915_mcu_get_txpower_sku(phy, txpwr, sizeof(txpwr)); if (ret) return ret; + buf = kzalloc(sz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + /* Txpower propagation path: TMAC -> TXV -> BBP */ len += scnprintf(buf + len, sz - len, "\nPhy%d Tx power table (channel %d)\n", -- 2.39.0