From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-eopbgr710095.outbound.protection.outlook.com ([40.107.71.95]:52685 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728945AbeIQI0f (ORCPT ); Mon, 17 Sep 2018 04:26:35 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Jean-Christophe Dubois , Eduardo Valentin , Sasha Levin Subject: [PATCH AUTOSEL 4.18 048/136] thermal: i.MX: Allow thermal probe to fail gracefully in case of bad calibration. Date: Mon, 17 Sep 2018 03:00:42 +0000 Message-ID: <20180917030006.245495-48-alexander.levin@microsoft.com> References: <20180917030006.245495-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030006.245495-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jean-Christophe Dubois [ Upstream commit be926ceeb4efc3bf44cb9b56f5c71aac9b1f8bbe ] Without this fix, the thermal probe on i.MX6 might trigger a division by zero exception later in the probe if the calibration does fail. Note: This linux behavior (Division by zero in kernel) has been triggered on a Qemu i.MX6 emulation where parameters in nvmem were not set. With this fix the division by zero is not triggeed anymore as the thermal probe does fail early. Signed-off-by: Jean-Christophe Dubois Reviewed-by: Fabio Estevam Signed-off-by: Eduardo Valentin Signed-off-by: Sasha Levin --- drivers/thermal/imx_thermal.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 334d98be03b9..b1f82d64253e 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -604,7 +604,10 @@ static int imx_init_from_nvmem_cells(struct platform_d= evice *pdev) ret =3D nvmem_cell_read_u32(&pdev->dev, "calib", &val); if (ret) return ret; - imx_init_calib(pdev, val); + + ret =3D imx_init_calib(pdev, val); + if (ret) + return ret; =20 ret =3D nvmem_cell_read_u32(&pdev->dev, "temp_grade", &val); if (ret) --=20 2.17.1