Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2087979ybp; Thu, 10 Oct 2019 01:59:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0bUdMRl1yPWkMfPHeeDrhXCzJvMdUWLuyU4GneJt8xaWEqb4VGqPpeRuFn3hEtf3CjytU X-Received: by 2002:a50:ed84:: with SMTP id h4mr6869729edr.124.1570697981508; Thu, 10 Oct 2019 01:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697981; cv=none; d=google.com; s=arc-20160816; b=eJ8wpaZsokuXtggmBVKBOrzxD4FKOFGifHLyezcyucbyOR/H91LyNK6IW2flIJLSTT UbvuzUDSwzw0XHtsiCDVFzZfmPrugEsb4dei1khuui5lRZxpwnuOqe97Z6Jaj5i6BLMt leEb0bqow3FknD7PEEMEZH0WZ4ReYqt3qIVj2fQXZY+lKW5aFuTZSXujUn1lERHBt1lo KcBbcyHiCGtBiWRtqZsvOGo2eLQC58hLNcxloipIzpUldowz7kFLmQy7I9bWC1uRxkHZ B/vwfEzSMbCd/HXfNfRRlYhX09Kef1q5DN3o8zzFj5YY4z5EHw0tTZBYaR07iMVmr7ny DykA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lnSQNdBYTDLRTtqi2shrsCx/wnHl6bSFOkfGTESNZy0=; b=Nu7MgU3RJ7mqNFyI9dWpHzwI3mVkcpC+GKRspvZVSJwjVC0Vq6BOxOBda/Jxei/8IN iXZ259wpSGw1nnCol+ytem9O3SyBshnWNtQCZATTEXFPF5zUfkNmzF4bdoUTLix67Jcm VxdKcaG8hU3dNrAhWhX8JECKtAxXd68lNTMssxhNJQm3sjBAI/ZEWCyrYKsERq2egqqB pUYDT474WEUsx/Dy8DGSPh6P/UdbmV9rEpMkX/StGBbsNgZXA6SSuU+T2dB36ALsuydR lDwe5q1bhYSXVrJTHkMz2SOCj4WgOso+e+Fxsu5ZJFL7NoI2ymcfCwjGHCFTcdR6MP39 BdZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JCO9wyqz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12si2684154ejp.103.2019.10.10.01.59.17; Thu, 10 Oct 2019 01:59:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JCO9wyqz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389454AbfJJIrV (ORCPT + 99 others); Thu, 10 Oct 2019 04:47:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:53132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388211AbfJJIrO (ORCPT ); Thu, 10 Oct 2019 04:47:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 86EE02064A; Thu, 10 Oct 2019 08:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697234; bh=lLf2g9KCQK5PoHP2qYZDVggikNw887AYHXv+3PO2oMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCO9wyqz6/n1XL8gk6qEF9uW8SwHd9kWkYo8u9NNo3ghzfxCYAZIOHdiBFHAQOj45 F+r1B06V5uSL4zXbPCUjWEYPS+jwqCvpdM/ofBknmndBDqPIEazQ6IerQzsmTsTFbW 7ENROUuaLW2a+Ad51249eE6wf6LAv5qs09vjqvwY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Mavrodiev , Zhang Rui , Sasha Levin Subject: [PATCH 4.19 066/114] thermal_hwmon: Sanitize thermal_zone type Date: Thu, 10 Oct 2019 10:36:13 +0200 Message-Id: <20191010083610.525336156@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083544.711104709@linuxfoundation.org> References: <20191010083544.711104709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Mavrodiev [ Upstream commit 8c7aa184281c01fc26f319059efb94725012921d ] When calling thermal_add_hwmon_sysfs(), the device type is sanitized by replacing '-' with '_'. However tz->type remains unsanitized. Thus calling thermal_hwmon_lookup_by_type() returns no device. And if there is no device, thermal_remove_hwmon_sysfs() fails with "hwmon device lookup failed!". The result is unregisted hwmon devices in the sysfs. Fixes: 409ef0bacacf ("thermal_hwmon: Sanitize attribute name passed to hwmon") Signed-off-by: Stefan Mavrodiev Signed-off-by: Zhang Rui Signed-off-by: Sasha Levin --- drivers/thermal/thermal_hwmon.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index 40c69a533b240..dd5d8ee379287 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -87,13 +87,17 @@ static struct thermal_hwmon_device * thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz) { struct thermal_hwmon_device *hwmon; + char type[THERMAL_NAME_LENGTH]; mutex_lock(&thermal_hwmon_list_lock); - list_for_each_entry(hwmon, &thermal_hwmon_list, node) - if (!strcmp(hwmon->type, tz->type)) { + list_for_each_entry(hwmon, &thermal_hwmon_list, node) { + strcpy(type, tz->type); + strreplace(type, '-', '_'); + if (!strcmp(hwmon->type, type)) { mutex_unlock(&thermal_hwmon_list_lock); return hwmon; } + } mutex_unlock(&thermal_hwmon_list_lock); return NULL; -- 2.20.1