Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2075394ybp; Thu, 10 Oct 2019 01:44:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2JiBNX9u29sqR7IbcpPz0pe1Mb2FR8/n/t8itdS1HLjeeXirxHthA5mCnhJ4i6rs/I1Ke X-Received: by 2002:aa7:d389:: with SMTP id x9mr7089216edq.33.1570697075661; Thu, 10 Oct 2019 01:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697075; cv=none; d=google.com; s=arc-20160816; b=JDXGow5xeptRVSoqMlYU47q0FMF+KuuUYDS3D5IZi2lcWB6FXVTnO+HSR4RvyR59hN RMKtNzR57C+hP4RkpFG0uRBfJLs7omf8d7zvz5DAIXIvnhXY2PnPck3/C9plIf5jFq4r 9NH9Q9jAOb64koy7q46qV3cRhpWyZplqTOo9xZwpZTOOAGrXdIL2DjMFTaQQHJIdScIo y0c7rDbcKg+yTlOZWFjizbqhKljbah25ABuxsPVD68SSKPlXyWrP+AAUnA1LnHoKpFQw +XIfqIWCYgAc7P9xgsvkM2EIWbxY9EzNoKbE8066ZXTyUwRxeasSJqAcPTAoJ6ULrji0 rm7w== 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=hrrNlS6SSK9XSCQM/NrIlRjn0DERdp8X6Fse3FPc/5XWVtdHe3gAxlyjQK3GQrBwNE sFkf92sBg6QBJq+rZ35hn3v9/hbe7mScKXJvhLcUxeyiY/+lgi9uwWBPiAK63uO44yhQ XmgTXI5F8d06SSaU1yhBIqelzzm+PoTyY3UryUCruA8Sk6BMD0eUZc7i5lJLZMYqPugf bRIDpCihYQ7gHsp7J8K/BcN8QfNxTuIejPlarP4zL3eOD5kBzUrPUgEa3/MNhWrs+BQP vo9JrY2Ppfd9pDALpkvj2xDnq62hkuYwLI54cFzGPdf+bWeq/Nd/zx5DELqRQ/EOqTVT H9QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1gPhiCXj; 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 bq16si2747549ejb.221.2019.10.10.01.44.12; Thu, 10 Oct 2019 01:44:35 -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=1gPhiCXj; 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 S2388595AbfJJIml (ORCPT + 99 others); Thu, 10 Oct 2019 04:42:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:47274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387910AbfJJImj (ORCPT ); Thu, 10 Oct 2019 04:42:39 -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 E5AE12190F; Thu, 10 Oct 2019 08:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696958; bh=lLf2g9KCQK5PoHP2qYZDVggikNw887AYHXv+3PO2oMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1gPhiCXjMVmiajjck1Ei6eMXm8PuC3l3A1HnRH4CLB01+jQ78X87/1LIhCWfa8eCa kiV5alLGx8qSnY+47uP1ee9qlL6mHfeVejRjKzq0ukH2z80zYRvtAj3HduQWxEMAYl JzPf9Sj8BpdvcC93q/j8HOPczlDOyqQYCaeDuJwg= 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 5.3 114/148] thermal_hwmon: Sanitize thermal_zone type Date: Thu, 10 Oct 2019 10:36:15 +0200 Message-Id: <20191010083618.018135079@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@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