Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp885930yba; Thu, 18 Apr 2019 11:12:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4Bg9p3+olvXv6j9rNOYGWf/21p4JLpZCMNdnsUYipKfTUtNU/rBY4X6VZf62AfeoNzTR6 X-Received: by 2002:a05:6a00:c1:: with SMTP id e1mr91099417pfj.143.1555611122889; Thu, 18 Apr 2019 11:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611122; cv=none; d=google.com; s=arc-20160816; b=XK7RjhXLzO4YOylHRexPCjxeI2mMCyO+XX0ILTRtdeZ3l7HRQD5kHTF3oib0/Wlwa9 AXNz9Cm8R8gZPZ2WKIGw4ELlvKdLBSKozv7OXcjZArTOdBC45aI32iPKMCWS9NJiimyc Zl7erQAqbD9vaStK0VKQRhhfR0HE1WatyEMLlw0sLTwLY/UXJrLZdL8Gzr0IsG97GU9p wgin6wfVM2wIybcEtJhNntpzH1+q4ve5rclAHNp+SE0JfO2JL9cBF7pKDpaK0IQjlKBM lQbKCMzmesZAvZ4lxj1AA2BOc21jzaD9zk8BDu7NkkJOQ+Fw3u51WiPG0sZsCilD9SAQ NbEQ== 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=j/C3TMhnBpeOW5UV4UYConOYOxj7BhWCXaICB2k7UPM=; b=Cm5OxOt7zFQpiFxDVCwT48N/rNcZXwCN8tCBIoOD7fxAI5DHUkII9Afa3jmh6rVbCe SiX+Oeoy/Il+7b8w3tgf4KxY22oZX5tH5dhr0HEsSyjnN1OuH5YMZj4+gJY/SFnYVol0 9XkIWNGEBNYf5sBlI38NDqMKzOqFU1FeNxzoF3EsR/ck5jc+UGBqZjp9Yi3qkc/Zmvxv mBu+oZl/xAPeQw5XTvlMDaXcKSeOPyHqmcauYFCupBxpD2+DOWIh1tmQl3RxsN73gtPK pttPQZwYzI31nto2Wc9/ehZ7vTt0UFGE9Q+9sfw9/0ZMBfRywEGFpD6wW16DTwSsgv2/ NvdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=anIxDgyL; 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 y6si2784113pll.50.2019.04.18.11.11.47; Thu, 18 Apr 2019 11:12:02 -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=anIxDgyL; 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 S2404075AbfDRSKK (ORCPT + 99 others); Thu, 18 Apr 2019 14:10:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:41784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403809AbfDRSKG (ORCPT ); Thu, 18 Apr 2019 14:10:06 -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 3E1EE206B6; Thu, 18 Apr 2019 18:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611005; bh=VqfAqdjv2UA9R3OtYQlfPqcKUrBwrpST/TsVByGc3ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=anIxDgyLdAuOTXboIV87BIn87RM1t4ARplyx7fVBBulweYaOukzUO3mWaZ74BcSyN BjoLHbg3q1ZS7CWGU9snNlVlOsVkw3ziyFiNDpCVTiRrIEgFoutaqCZ9g1CwBYtbqu ouwQQLqAgN6/Kb5skiQTiPzdci1OEFez8ucw29eA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Phil Elwell , Zhang Rui , Sasha Levin Subject: [PATCH 5.0 22/93] thermal: bcm2835: Fix crash in bcm2835_thermal_debugfs Date: Thu, 18 Apr 2019 19:57:00 +0200 Message-Id: <20190418160438.986278963@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@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 [ Upstream commit 35122495a8c6683e863acf7b05a7036b2be64c7a ] "cat /sys/kernel/debug/bcm2835_thermal/regset" causes a NULL pointer dereference in bcm2835_thermal_debugfs. The driver makes use of the implementation details of the thermal framework to retrieve a pointer to its private data from a struct thermal_zone_device, and gets it wrong - leading to the crash. Instead, store its private data as the drvdata and retrieve the thermal_zone_device pointer from it. Fixes: bcb7dd9ef206 ("thermal: bcm2835: add thermal driver for bcm2835 SoC") Signed-off-by: Phil Elwell Signed-off-by: Zhang Rui Signed-off-by: Sasha Levin --- drivers/thermal/broadcom/bcm2835_thermal.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c index 720760cd493f..ba39647a690c 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c @@ -119,8 +119,7 @@ static const struct debugfs_reg32 bcm2835_thermal_regs[] = { static void bcm2835_thermal_debugfs(struct platform_device *pdev) { - struct thermal_zone_device *tz = platform_get_drvdata(pdev); - struct bcm2835_thermal_data *data = tz->devdata; + struct bcm2835_thermal_data *data = platform_get_drvdata(pdev); struct debugfs_regset32 *regset; data->debugfsdir = debugfs_create_dir("bcm2835_thermal", NULL); @@ -266,7 +265,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) data->tz = tz; - platform_set_drvdata(pdev, tz); + platform_set_drvdata(pdev, data); /* * Thermal_zone doesn't enable hwmon as default, @@ -290,8 +289,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) static int bcm2835_thermal_remove(struct platform_device *pdev) { - struct thermal_zone_device *tz = platform_get_drvdata(pdev); - struct bcm2835_thermal_data *data = tz->devdata; + struct bcm2835_thermal_data *data = platform_get_drvdata(pdev); + struct thermal_zone_device *tz = data->tz; debugfs_remove_recursive(data->debugfsdir); thermal_zone_of_sensor_unregister(&pdev->dev, tz); -- 2.19.1