Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9112643pxu; Mon, 28 Dec 2020 06:59:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjqfs2gzU2gJa8Ikt2F+DBUgoQqcrvbEdR2OD2fbutLLwQ2Ejf0NN3ViUjybWnIpe0vcpt X-Received: by 2002:aa7:d3d4:: with SMTP id o20mr42232525edr.190.1609167563230; Mon, 28 Dec 2020 06:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167563; cv=none; d=google.com; s=arc-20160816; b=cW4DqKIevY30QPyh/aDVst5DZ5Vr1fANPPXEnvFM9OeA8iPSarL1Y5oJ/3sEPU0ing 1JqXbjUYpL9egHIQJpJBvEEUhQdTiNa4spwbKl9Yc1K3cz6bDxnp1o8u/R2CWlEPgRqP M3Z4Ps1ahQXDwuNwS4csjTuqvB/hXOLeAGccn5xMbAnSujlNDYZ5a+DoUQM+fDIYp3Qm A7lH0/DTNNH2LZLyw/TpvMzG3Jc/SVoaofFGUNN9C9cDOzSGZmZZ4EPHxQ76UNZkwQZy +TeMrOz5p+FUp0QArRKkaINFlSo5cQz6mRYAStBzr+Mu9kVfsX173t7qsguF50iiBWn/ xn6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=t07DkR+n2P9p2pM3uKum00OWuvKGckNw4fWo0jm0NoM=; b=BUBlcWnioS9b4AFlcfU6lxich8ts8i5TY6Y5IZkhf1IKzZMW7zndhsU7asFTto/hUF +qmeG/TK+CsUjQvcg75v1jsBQf/+qGGtMcvOF6JzVqCIsvi40JOXMTQaAuHJbfrw/53N kZ2auyR9zkMI/epXrzTTipmQpG4bi8MZZ2KbeC2ONE8dvWH4HUHPn44gRvhaqVz5jUxW 6rB9JUKx8QXSiE/EQ51v/x08/qatYHviWSqRCt7bjoZ7nV2zngpp/AKB0bq1KA7tCn67 oGXlKfT4alW0Jq5NOHYfZJiwjcpYw5OemCjp0kFKYMc1qqJiP004Cy2rEXdWgrCK42zq 6hrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q5fKjzN3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si18865529ejt.469.2020.12.28.06.59.00; Mon, 28 Dec 2020 06:59:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q5fKjzN3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408101AbgL1Ozv (ORCPT + 99 others); Mon, 28 Dec 2020 09:55:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:52136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441219AbgL1ORB (ORCPT ); Mon, 28 Dec 2020 09:17:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C283022AAA; Mon, 28 Dec 2020 14:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164980; bh=hBwo5UXRJC0YzTAz3HQDeIVycszqgjZdqb20HN6tMYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q5fKjzN3NuTuQsa5bWbLWTioYy/8T+gWXinw1Awio7VjIxzGPaDGKoUJfLKGiUXIm GWaFa3O7djSX353o2IhlnF+k7hnXYnmxGHPaR7VNrM0ivCpelXXI6BnUaY2bj0N+91 MRfXWY5XCgeNfo8+4JGv92Ss2YLBPHV4/xpOzJZo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Vinod Koul , Sasha Levin Subject: [PATCH 5.10 367/717] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message Date: Mon, 28 Dec 2020 13:46:05 +0100 Message-Id: <20201228125038.589605736@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit b097efba9580d1f7cbc80cda84e768983e3de541 ] Currently there is a null pointer check for hdmi_phy that implies it may be null, however a dev_err messages dereferences this potential null pointer. Avoid a null pointer dereference by only emitting the dev_err message if hdmi_phy is non-null. It is a moot point if the error message needs to be printed at all, but since this is a relatively new piece of code it may be useful to keep the message in for the moment in case there are unforseen errors that need to be reported. Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file") Signed-off-by: Colin Ian King Addresses-Coverity: ("Dereference after null check") Link: https://lore.kernel.org/r/20201207150937.170435-1-colin.king@canonical.com [vkoul: fix indent of return call] Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c index 47c029d4b270b..206cc34687223 100644 --- a/drivers/phy/mediatek/phy-mtk-hdmi.c +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy) hdmi_phy->conf->hdmi_phy_disable_tmds) return &mtk_hdmi_phy_dev_ops; - dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n"); - return NULL; + if (hdmi_phy) + dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n"); + return NULL; } static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy, -- 2.27.0