From patchwork Mon Oct 3 13:29:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12997582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DCF3C433FE for ; Mon, 3 Oct 2022 13:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=x28iTVOz3rjt9QePo/i7Ui6405qkVReDjtMIOE6Ut7A=; b=04WIN/TRNa/LLR DRUjeyoQsg+abRQ9OOTt050ofwuoGXNESc2WfHo7H2njAZ/Lf7MnnI7Pgj8q6z1hLufRyps2/zYJQ MXqBwonhpF3iTCZ0sp6jQ8KAA+JSM/bStKU1da34G3+w8wDbMuMdLPlfgdi6eqwc0T7htgRjcUOOH B/xCYZzoKYY3Dl1hgnWlgn6VQ5qyXDIfhMba9UiSMxkX0jRdDDqRRkvLPGpiIq/TdR0kNDuQ4R4Kd 9YrgIuu/aU58pYBPTILQZ8RYg7PU70PWGabgbdK9/4Zv7ELd/MA2E15BuisAT761YJQ9XOTPpRG5r KHVXz0NRotWC4djxaP5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofLWN-0060LJ-NX; Mon, 03 Oct 2022 13:30:11 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofLWK-0060Ir-1U for linux-arm-kernel@lists.infradead.org; Mon, 03 Oct 2022 13:30:09 +0000 Received: by mail-wr1-x434.google.com with SMTP id j7so11390770wrr.3 for ; Mon, 03 Oct 2022 06:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=K+1rfxoYuPGVyugbqBQnz5TOkQnrFnazhzmXLe5x1kk=; b=YdGNxZrDeq2Ca5oDBn0BNqMa8Pd5/9myYbWwsZv1k5Wac00ZwsjY9ks1spfrTh9gus nJhnNAqYRyvk1MbskUc1n3ZLd1vQ4Gmgnde1f1i5FXKrLcBeA3oyS3cWU6V7LQjDxNCz /a93+1JnCWlFIaJgJRzWvHGXYj22l54rDzS49oyHOQ3gxGBChSVmMXIoC3DHVQBSMwai VPeJY6y0xqGq5+LHjQyl+we/zZzUgsgC9mqqjFmf8216XpWvzoOX9gHfKKcLujhZD1Rx Le+8s4Vrd9AwddaQvd0yyQ9JdG4RFrcTsm0UAJ2ll8y0FNkEJuK2hDaOrYbQhXk5uhzv NFGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=K+1rfxoYuPGVyugbqBQnz5TOkQnrFnazhzmXLe5x1kk=; b=SIxlqRMY1cUWzTdoKfrh6EwGxDCC/P7RFfKfiGKKlqwS8NH+P3syY7PDRhF4eQFPvm M+hByYfGwDO3wiDEeooLauV8A4dDCFBZdaDjj580WoMBE20HUUQ9jiFHQj9pl9IA4BtH pm9yWPb/azoBipV7rjmiElSiYGNWnUYa2lVgUZodctq0oBxAepQxPl+++pgKiyQcLNuY em4NxhEUQvELGdEKOJPavPRMfYO7+2JkHjQb4WFLiF93RG1hXi6DA9o7a7Qkywjewikf UojFZjv0e6uyl16S4iE/W1ihyxYaJ5fLhBU5vQetx15HoG6cWgvuygYtQw9CCk7oKrzC BysQ== X-Gm-Message-State: ACrzQf0kVDMf9J6n367/z91R5M4c0hdcvWIMXj8/vou0I4ijr+E6SQZP kw83ohz82RzvYdk7vYGRd4BYIw== X-Google-Smtp-Source: AMsMyM66s2c6ioMSZWAOxcHBd1FcbmLW5V+HHMEDhVA8STfMvwpfd9at2Qn2qlj4JsImewOqQjoK3A== X-Received: by 2002:a5d:65c4:0:b0:22c:dbdd:7177 with SMTP id e4-20020a5d65c4000000b0022cdbdd7177mr11291303wrw.470.1664803803837; Mon, 03 Oct 2022 06:30:03 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:f3a:9f5e:1605:a75a]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c4f5500b003a5f54e3bbbsm18379931wmq.38.2022.10.03.06.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 06:30:03 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org, m.szyprowski@samsung.com Cc: Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Amit Kucheria , Zhang Rui , Alim Akhtar , linux-pm@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] thermal/drivers/exynos: Fix NULL pointer dereference when getting the critical temp Date: Mon, 3 Oct 2022 15:29:43 +0200 Message-Id: <20221003132943.1383065-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <4e4d873b-4a40-334a-34e7-defb0fcc4e6b@samsung.com> References: <4e4d873b-4a40-334a-34e7-defb0fcc4e6b@samsung.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221003_063008_112664_BB0EBBEF X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver is assuming the get_critical temperature exists as it is inherited by the thermal of ops. But this one has been removed in favor of the generic one. Use the generic thermal_zone_get_crit_temp() function instead Fixes: 13bea86623b ("thermal/of: Remove of_thermal_get_crit_temp(") Reported-by: Marek Szyprowski Signed-off-by: Daniel Lezcano Reviewed-by: Krzysztof Kozlowski Tested-by: Marek Szyprowski --- drivers/thermal/samsung/exynos_tmu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 5a1ffe2f3134..37465af59262 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -264,9 +264,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) unsigned int status; int ret = 0, temp; - if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */ - ret = tzd->ops->get_crit_temp(tzd, &temp); - if (ret) { + ret = thermal_zone_get_crit_temp(tzd, &temp); + if (ret && data->soc != SOC_ARCH_EXYNOS5433) { /* FIXME */ dev_err(&pdev->dev, "No CRITICAL trip point defined in device tree!\n"); goto out;