Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp76748pxv; Fri, 30 Jul 2021 19:18:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGi661aLTzMF915kmV1dTCrOjpPH1OhT4MGbPkdQXqYkFoDmdklom+5pnzRN7wU9Oojz67 X-Received: by 2002:a05:6e02:1c2d:: with SMTP id m13mr3078037ilh.137.1627697887335; Fri, 30 Jul 2021 19:18:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627697887; cv=none; d=google.com; s=arc-20160816; b=wSUZwezNAe+TMBGMGXGBgj57OGVOvX6170/JiB090kYa3IuRPy2XzEZ/UoTjvJEaV+ pJgv9slpCCx4MFLN7yiXRYb7qzWSCH7kZAMwCvXbvpCtstlZuCHTcDBw39+PUawxwvYT G9IfIb1JHU2aGgtoRgdxNETRneOdc3MK4cgB9MAFHhPI6ywrNozY+xSZCmmP9YoZMoLs j9GWluov2yRReDbvIkjS+Ju48J8swLSqo0K2ZnA3N+B8Hw92IEHNJr8DRXnQ952ev2An NRpYXgdZI7Zc0q5UIJ5SgT0In8awjz7GPq+2JF4cw4Wo2zfc6O87DDHS72WUueoBKx7N H3+g== 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; bh=XFuADQxmka5K+684fzopw7TJUgX1EB2OujkPqWtVj6A=; b=OsHKO2pDlHkYHrS45x1YpnE0ePN77Hz8ZvZ8ulBbT9As96D+33Naf2oXBAu3nNGWGc s0ZAMFgQvu4i02XdOQ0iCchpSlGm8fjBopcxqE8AMwQnW4+OI4TJxLx6mMJK4JAIo3e/ bKcEINIYYessIghNj2wmZEYA6Gn+I5AYvKDpJynpDEni29peoRo40bw0z6JxWTYdpUtS pgH/L+7V73wV6gNhcMi7IYebJoZQOPXPb4L7ZAS5i/JwR9R1iBz9pe1Y+H6WzfiLrOE9 ePMRmOwQxkdxHzVHjep610C47gW5oQm3ev2XKK8pahWu9GOathj6QGybF/vU0K0Uehns vnuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si3782325ioo.61.2021.07.30.19.17.45; Fri, 30 Jul 2021 19:18:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235961AbhGaCRm (ORCPT + 99 others); Fri, 30 Jul 2021 22:17:42 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:60846 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231464AbhGaCRl (ORCPT ); Fri, 30 Jul 2021 22:17:41 -0400 X-UUID: 9f53958af566410cb811042340d5a19b-20210731 X-UUID: 9f53958af566410cb811042340d5a19b-20210731 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1074251285; Sat, 31 Jul 2021 10:17:31 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 31 Jul 2021 10:17:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 31 Jul 2021 10:17:30 +0800 From: Ryder Lee To: Felix Fietkau CC: Lorenzo Bianconi , Shayne Chen , Evelyn Tsai , , , Ben Greear , Ryder Lee Subject: [PATCH v4 1/2] mt76: mt7915: fix hwmon temp sensor mem use-after-free Date: Sat, 31 Jul 2021 10:17:27 +0800 Message-ID: <9f5b0cf6c4296d3a9e78a95516cf26d1db4baba9.1627696765.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear Without this change, garbage is seen in the hwmon name and sensors output for mt7915 is garbled. With the change: mt7915-pci-1400 Adapter: PCI adapter temp1: +49.0°C Fixes: d6938251bb5b (mt76: mt7915: add thermal sensor device support) Signed-off-by: Ben Greear Signed-off-by: Ryder Lee --- v4: Simplify flow. v3: Add 'fixes' tag to aid backports. --- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index 77c7486d6a5c..a1b9e1b3f700 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -155,13 +155,13 @@ static void mt7915_unregister_thermal(struct mt7915_phy *phy) thermal_cooling_device_unregister(phy->cdev); } -static int mt7915_thermal_init(struct mt7915_phy *phy) +static int mt7915_thermal_init(struct mt7915_phy *phy, const char *prefix) { struct wiphy *wiphy = phy->mt76->hw->wiphy; struct thermal_cooling_device *cdev; struct device *hwmon; - cdev = thermal_cooling_device_register(wiphy_name(wiphy), phy, + cdev = thermal_cooling_device_register(prefix, phy, &mt7915_thermal_ops); if (!IS_ERR(cdev)) { if (sysfs_create_link(&wiphy->dev.kobj, &cdev->device.kobj, @@ -175,7 +175,7 @@ static int mt7915_thermal_init(struct mt7915_phy *phy) return 0; hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, - wiphy_name(wiphy), phy, + prefix, phy, mt7915_hwmon_groups); if (IS_ERR(hwmon)) return PTR_ERR(hwmon); @@ -403,7 +403,7 @@ static int mt7915_register_ext_phy(struct mt7915_dev *dev) if (ret) goto error; - ret = mt7915_thermal_init(phy); + ret = mt7915_thermal_init(phy, KBUILD_MODNAME "-ext"); if (ret) goto error; @@ -853,7 +853,7 @@ int mt7915_register_device(struct mt7915_dev *dev) if (ret) return ret; - ret = mt7915_thermal_init(&dev->phy); + ret = mt7915_thermal_init(&dev->phy, KBUILD_MODNAME); if (ret) return ret; -- 2.29.2