Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1784061pxp; Mon, 7 Mar 2022 02:13:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsY6kPzCO1lgNv1q4mhcTe3VoDs9sKJMpWXxWJ1Pi5Z/VkxuhcLniLUnc1z93g9GbwyKHf X-Received: by 2002:a17:907:6d86:b0:6da:86b9:ac3 with SMTP id sb6-20020a1709076d8600b006da86b90ac3mr8676283ejc.532.1646648029079; Mon, 07 Mar 2022 02:13:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646648029; cv=none; d=google.com; s=arc-20160816; b=xcxJrFi8taHCqmDmfXBQtdaUhXK0c9y7b1RBQp7SRypOphnYzDadlyRb4GzPJNr/H4 RwJCJox88Y3+2uxYG+4+Ox9XgKk/pQaak19ggpsL5uPhN6eF7VSEpPxYVqea97Xru0Xy EQskdZZhIB+WS0MCfE3I+N9aHzFoocFuDPBlDFL6hSITkX/PgMdf/HWeXEYsfRbuNenr VOjcmapLWNX+/b2AUxqdH6j+RWiFRJsw/o/lpM1O02FokGqAvprIfBUGuX8IR2iGd3Hi uWgf+YPmHp1Byjg+ZTY0ry1OA9QVkGHl39Dn+hRxBE3PprB9u7sX5+D9WnTQURHLt5Nq fpDw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pj+4Eq/i66kPt5es775Q7JRwo3FqljJIKUYg57nlM54=; b=U6UtWueRPi4t3/IZP8w4lQ5NK9++7Q8nAnsIMYIFpbrQR5JH3z+TOWKWHuU2jH9GTF v2Remlz7BE1kx1nc6GWo9Gf61tdmYENWbtuXVa3sapf7ZoRFHdXYLCou2EA29mzRZ1WC 62jS/gwmXusABI1gfkLYrHoCf1egP0BMp+1DVmY5UpgOFRyAjQTRZVjBb2ZWV9pAxskI IIGeqI3YFYHSf0S8fl+AWgNyUATwc8ufKenAQjGvPQNuzCPYRccKtrmUJeW1IPVdGiQf u+auicz3WTLCJFtelBLX2ksvHoLI9u6FznfBwd0R+Q1EKH4LJhLy4jxu9GSicZxc+T6e tndQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=prVpmwuL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z20-20020a05640235d400b004165be66103si558207edc.207.2022.03.07.02.13.26; Mon, 07 Mar 2022 02:13:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=prVpmwuL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238371AbiCGJpI (ORCPT + 99 others); Mon, 7 Mar 2022 04:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237205AbiCGJdp (ORCPT ); Mon, 7 Mar 2022 04:33:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7157A6D38B; Mon, 7 Mar 2022 01:30:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 12D8E61119; Mon, 7 Mar 2022 09:30:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2510DC340E9; Mon, 7 Mar 2022 09:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645442; bh=0XM5ZexUMskW4ZkOyUw7cgz87x2gisU6TaKUIornEEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=prVpmwuLgIooonbIepHM5R4nCKar+VYa+QwRltxUO8GtROqW4x0T/8m+EOEBiB4GL /LmoNR4Wan3OcbhSb/sO+UboaqdV/t1QW157tW6NcomarZ4IRJgdsVCmXAGTInGsOA NnS9Ra/0TmrrChIODtxha+1MKoezJ8yI2BrYWQm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Cavallari , "Rafael J. Wysocki" Subject: [PATCH 5.10 033/105] thermal: core: Fix TZ_GET_TRIP NULL pointer dereference Date: Mon, 7 Mar 2022 10:18:36 +0100 Message-Id: <20220307091645.116487211@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091644.179885033@linuxfoundation.org> References: <20220307091644.179885033@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicolas Cavallari commit 5838a14832d447990827d85e90afe17e6fb9c175 upstream. Do not call get_trip_hyst() from thermal_genl_cmd_tz_get_trip() if the thermal zone does not define one. Fixes: 1ce50e7d408e ("thermal: core: genetlink support for events/cmd/sampling") Signed-off-by: Nicolas Cavallari Cc: 5.10+ # 5.10+ Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/thermal/thermal_netlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -418,11 +418,12 @@ static int thermal_genl_cmd_tz_get_trip( for (i = 0; i < tz->trips; i++) { enum thermal_trip_type type; - int temp, hyst; + int temp, hyst = 0; tz->ops->get_trip_type(tz, i, &type); tz->ops->get_trip_temp(tz, i, &temp); - tz->ops->get_trip_hyst(tz, i, &hyst); + if (tz->ops->get_trip_hyst) + tz->ops->get_trip_hyst(tz, i, &hyst); if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) || nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, type) ||