From patchwork Sat Jul 31 02:17:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 12412207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53920C4338F for ; Sat, 31 Jul 2021 02:18:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C2DF60F46 for ; Sat, 31 Jul 2021 02:18:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0C2DF60F46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dyt1+jTbLQSvDTuEZnjZ1yFcoI+RwQVdu2aMrQnZd9I=; b=rhl95eAyIAOtNM HMqSFGrhli/hzV1OWTz86XWdJOasS3yYf6FbK4QHfnv1AVGrlHaDoyZ0N9emtnfn8nmbxUu+VyYoq CDHe/AArxRMRYB8iP3WRnHzml3OVcV0HX9DqenLgD0jIWHcjlvmS6ifSMU7A7kKuzLUq7SgK11aZm kqTRA/+cUs4T6K4u2qhLiLMrx1B7HqF8YKknAZ+HNMrlXhzvEu4MKF23FTuQMCDa4t9s53Oj8+wWd R6AIgYrJMsXXvNFEzJiCS8bME1cTd4hINk6gi5T6CKNP6cHVQ4j8TlEjPPBEUS/lYZW2gfuHYB7xF 68Ax4gV/np9n3m38bx7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9eZK-00AkZf-9D; Sat, 31 Jul 2021 02:17:42 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9eZG-00AkZ9-1O for linux-mediatek@lists.infradead.org; Sat, 31 Jul 2021 02:17:40 +0000 X-UUID: c519ffb68cc7432484c0a0de8d4ba61f-20210730 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=2uKRFPayNGkXadG8vVCANzq7vJL5MeDSDQQeojWO0og=; b=P8trn4AiPKNvlqm9o97/XS+2Vz70LD3ENeR6NXOQl9VL+QNVxORYqWHBDoJ/VhEqQuINZfDZX0YiVxHrDCP0J29ILExrDqyxhHXa6+YlLx7qx43whhrPabJYawEl0wizuLOwVrONhyABvVN/EffM7iFM2G0W/k7WyjI2sSgLnvs=; X-UUID: c519ffb68cc7432484c0a0de8d4ba61f-20210730 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1294813483; Fri, 30 Jul 2021 19:17:33 -0700 Received: from mtkmbs05n2.mediatek.inc (172.21.101.140) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 30 Jul 2021 19:17:31 -0700 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 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210730_191738_139060_EB692E89 X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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;