Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756051AbbBPOUa (ORCPT ); Mon, 16 Feb 2015 09:20:30 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:30109 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752636AbbBPOUV (ORCPT ); Mon, 16 Feb 2015 09:20:21 -0500 X-AuditID: cbfee68d-f79296d000004278-d2-54e1fca2825a From: Chanwoo Choi To: rui.zhang@intel.com, edubezval@gmail.com Cc: kgene@kernel.org, b.zolnierkie@samsung.com, kyungmin.park@samsung.com, amit.daniel@samsung.com, l.majewski@samsung.com, a.kesavan@samsung.com, inki.dae@samsung.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Chanwoo Choi Subject: [PATCH 1/3] thermal: exynos: Fix NULL pointer exception during kernel booting Date: Mon, 16 Feb 2015 23:20:12 +0900 Message-id: <1424096414-4327-2-git-send-email-cw00.choi@samsung.com> X-Mailer: git-send-email 1.8.5.5 In-reply-to: <1424096414-4327-1-git-send-email-cw00.choi@samsung.com> References: <1424096414-4327-1-git-send-email-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRmVeSWpSXmKPExsWyRsSkQHfRn4chBlNPa1o8XrOYyaLhaojF xhnrWS2uf3nOajH/yjVWi0n3J7BY9D9+zWxxtukNu8Wbh5sZLTY9Bkpc3jWHzeJz7xFGixnn 9zFZPHnYx+bA57Fz1l12j8V7XjJ5bFrVyeaxeUm9R9+WVYwenzfJBbBFcdmkpOZklqUW6dsl cGWcm3GIreClRMWJiTOZGhgPiHYxcnBICJhIHO+V62LkBDLFJC7cW88GYgsJLGWUeHs8Gqbk 3uqILkYuoPB0Rom52/+zQjhNTBLHL19lB2lgE9CS2P/iBliziICOxOEnT5lBipgFrjFJ3D9y AiwhLBAhcaL7MSuIzSKgKrH0wUdWk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f3g8rDECHWxLLiytxDjBIczEoivMveA4V4UxIrq1KL8uOLSnNSiw8xmgIdNZFZ SjQ5H5gs8kriDY1NzIwsjcwNLYyMzZXEeZXs20KEBNITS1KzU1MLUotg+pg4OKUaGDk/WPvI KXPlfRBsduqY7PW+0Y9B79DhqJNLbKWFxNff8+I88TPM7iTLpijrvydfWIstPxmt+XVKa8mp OA3/hdMKGFZU1hm9198vV/x55sWI91F8h3ZtOLzp7CoB/3lvv8y9zsm4jnnWHZUH7Tek3vbP i756QG9WeGa0ZPfifrFtGi1SVw8+ZlRiKc5INNRiLipOBAC58QPb3gIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3349 Lines: 78 This patch fixes the NULL pointer exception during kernel booting. The thermal_zone _of_sensor_register() registers a sensor to DT thermal zone and then read the current temperature by '.get_temp' callback. The callback function of exynos thermal driver is exynos_get_temp() which must need the 'pdata' instance of exynos_tmu _platform_data structure. - exynos_get_temp() -> code_to_temp() -> Must need the 'pdata' instance But, exynos thermal driver is executed before getting the 'pdata' instance. To avoid the kernel panic, have to get the platform data by executing the exynos_map_dt_data() before calling thermal_zone_of_sensor_register() . - kernel panic log [ 4211.324346] PC is at 0x0 [ 4211.326867] LR is at exynos_get_temp+0x3c/0xe4 [ 4211.331289] pc : [<0000000000000000>] lr : [] [snip] [ 4211.940625] [< (null)>] (null) [ 4211.945315] [] of_thermal_get_temp+0x1c/0x30 [ 4211.951132] [] thermal_zone_get_temp+0x48/0x7c [ 4211.957118] [] thermal_zone_device_update+0x20/0x110 [ 4211.963627] [] of_thermal_set_mode+0x44/0x68 [ 4211.969443] [] thermal_zone_of_sensor_register+0x15c/0x1d8 [ 4211.976475] [] exynos_tmu_probe+0x6c/0x814 [ 4211.982120] [] platform_drv_probe+0x48/0xb8 [ 4211.987846] [] driver_probe_device+0x8c/0x244 [ 4211.993747] [] __driver_attach+0x98/0xa0 [ 4211.999216] [] bus_for_each_dev+0x54/0x98 [ 4212.004771] [] driver_attach+0x1c/0x28 [ 4212.010066] [] bus_add_driver+0x150/0x208 [ 4212.015622] [] driver_register+0x5c/0x11c [ 4212.021178] [] __platform_driver_register+0x5c/0x68 [ 4212.027600] [] exynos_tmu_driver_init+0x14/0x20 [ 4212.033678] [] do_one_initcall+0x88/0x1a0 [ 4212.039235] [] kernel_init_freeable+0x1bc/0x260 [ 4212.045311] [] kernel_init+0xc/0xd8 Cc: Zhang Rui Cc: Eduardo Valentin Signed-off-by: Chanwoo Choi --- drivers/thermal/samsung/exynos_tmu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index fbeedc0..b8846f1 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -1147,17 +1147,17 @@ static int exynos_tmu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); mutex_init(&data->lock); + ret = exynos_map_dt_data(pdev); + if (ret) + return ret; + pdata = data->pdata; + data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data, &exynos_sensor_ops); if (IS_ERR(data->tzd)) { pr_err("thermal: tz: %p ERROR\n", data->tzd); return PTR_ERR(data->tzd); } - ret = exynos_map_dt_data(pdev); - if (ret) - goto err_sensor; - - pdata = data->pdata; INIT_WORK(&data->irq_work, exynos_tmu_work); -- 1.8.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/