Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp833304pxb; Wed, 1 Sep 2021 10:52:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeNsNznUQWV4UkKYF/boUIDGW4y7qR/Xu8FwGPQkyoTXiGIBNS7K3S5aMFi//SzCXHg1GO X-Received: by 2002:a05:6602:2c05:: with SMTP id w5mr650311iov.160.1630518734597; Wed, 01 Sep 2021 10:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630518734; cv=none; d=google.com; s=arc-20160816; b=QeAkOZzZg8rOnBLENZIMrvXN+0syxhmP7NEABU4QCWh/2WXnyFjKzoSTbXADfy2le0 6cALYhHzTOiTCeY5YRfarqFPTi1fPWCvO6vhklETjSsL8RQoH3IxWbS47w1nsoqfQn65 Xf9mIjrHGInL8o9l2sisSSTMC6/ln63rgrCuXiFORSEevxtEWleThKUwNcAQEEdAWywN 90RCbgNALLkgXYzs2ZQ3XjZ493xNLNwUXt6dj2G2U4/4HVrVEkBIEoozKZOzyFCs0qAM 8RpLiWyyDLJ6nvfoVyuSbBzVmXUUeS77M5A7TiihsF/ONj7JBP+zah6BqffndGVgTYHw kbag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=V+BJ5FVPEOborG6tHaBh+LchePP2Z8zFmV815opP6Oc=; b=mBx9WjYO3wNPhnK20wdcgrX8bltHBl9J75yEW66JpcLARJFY+a+8TRVjF2cFUpkk0n KjcsDgOeJXR+aBjmLAdpgR4ZnsniIeZfyO56NmtGfwy2gL0uA48BImyIifxZrZSBHt+4 jKW7NKzTw58vFI9rTPlEsQYuDySKQ84DD2+xm9yWvYI/89DqfDSczABKUMz/IegiH8sa xj2dOx4Aiar0zbZCyjz8XnamH/ZgzFXhzD18ahtjI+BDzADraF5DZM0g5YYBMliTs2Z+ CbdFIDNJWp8kwY+pWoy7txmBD67uqfKPwRKTnBr4+h9nMyUU/eAOxT0pIHy1FsMBeDXW cFjg== 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 l30si98354jaf.107.2021.09.01.10.51.58; Wed, 01 Sep 2021 10:52:14 -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 S1346720AbhIARvh (ORCPT + 99 others); Wed, 1 Sep 2021 13:51:37 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:32830 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1347245AbhIARuf (ORCPT ); Wed, 1 Sep 2021 13:50:35 -0400 X-UUID: 1855732033c247dc9f36526994bfad6f-20210902 X-UUID: 1855732033c247dc9f36526994bfad6f-20210902 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 375468517; Thu, 02 Sep 2021 01:49:36 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 2 Sep 2021 01:49:35 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 2 Sep 2021 01:49:35 +0800 From: Ryder Lee To: Felix Fietkau CC: Lorenzo Bianconi , Shayne Chen , Evelyn Tsai , , , Ryder Lee Subject: [PATCH v5 2/2] mt76: mt7615: fix hwmon temp sensor mem use-after-free Date: Thu, 2 Sep 2021 01:49:31 +0800 Message-ID: <650546c0dee92042fc019941786cfdbce2424812.1630515790.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Without this change, garbage is seen in the hwmon name and sensors output for mt7615 is garbled. Fixes: 109e505ad944 ("mt76: mt7615: add thermal sensor device support") Signed-off-by: Ryder Lee --- v5: Use devm_kstrdup on the wiphy name as suggested. --- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c index 05235a60d413..7c584ca43b2d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c @@ -49,12 +49,13 @@ int mt7615_thermal_init(struct mt7615_dev *dev) { struct wiphy *wiphy = mt76_hw(dev)->wiphy; struct device *hwmon; + const char *name; if (!IS_REACHABLE(CONFIG_HWMON)) return 0; - hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, - wiphy_name(wiphy), dev, + name = devm_kstrdup(&wiphy->dev, wiphy_name(wiphy), GFP_KERNEL); + hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, name, dev, mt7615_hwmon_groups); if (IS_ERR(hwmon)) return PTR_ERR(hwmon); -- 2.29.2