Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2532482D9; Mon, 11 Dec 2023 14:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mvTDGt/6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CB06C433C8; Mon, 11 Dec 2023 14:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702303367; bh=X8BcZbwp3MScYiolNRocaQ2haYm8pGOwTNtJJ9H0s74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mvTDGt/6NnjDcxFsBAYyhOkqoyWSBJdEseHtngKzQqkHgVpgIwmXAVrdcU9Plpbqr Ce61BlEkrTRbZrVaWBcm5A28fOfAX1TEM1I5phaCb3pL2o1FTX1XF0mTfvE4n7xslG pXH2u+/zpJkQEKyRzkx26DHqzsoI2fox79bawGZO2INLJpKTJ8slrwh77CwTDGQtTx MSkfAPSL5lNf8sn7Wlc6J65lgG9+qnxkRaOjb6qnhKuVEAGPkN019VFSk0tPwYQM0z Mx2/deASbkiNiBBzRVanplU1QzE0g/VzQPao0gaJPaIZxnc+MuCqtNxi1I8JKtYS1L 5Ruphe1sH7teA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xiang Yang , Inki Dae , Sasha Levin , sw0312.kim@samsung.com, kyungmin.park@samsung.com, airlied@gmail.com, daniel@ffwll.ch, krzysztof.kozlowski@linaro.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 11/12] drm/exynos: fix a potential error pointer dereference Date: Mon, 11 Dec 2023 09:02:04 -0500 Message-ID: <20231211140219.392379-11-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231211140219.392379-1-sashal@kernel.org> References: <20231211140219.392379-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.4.263 Content-Transfer-Encoding: 8bit From: Xiang Yang [ Upstream commit 73bf1c9ae6c054c53b8e84452c5e46f86dd28246 ] Smatch reports the warning below: drivers/gpu/drm/exynos/exynos_hdmi.c:1864 hdmi_bind() error: 'crtc' dereferencing possible ERR_PTR() The return value of exynos_drm_crtc_get_by_type maybe ERR_PTR(-ENODEV), which can not be used directly. Fix this by checking the return value before using it. Signed-off-by: Xiang Yang Signed-off-by: Inki Dae Signed-off-by: Sasha Levin --- drivers/gpu/drm/exynos/exynos_hdmi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 0073a2b3b80a2..93b2af4936d0e 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -1850,6 +1850,8 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data) return ret; crtc = exynos_drm_crtc_get_by_type(drm_dev, EXYNOS_DISPLAY_TYPE_HDMI); + if (IS_ERR(crtc)) + return PTR_ERR(crtc); crtc->pipe_clk = &hdata->phy_clk; ret = hdmi_create_connector(encoder); -- 2.42.0