Skip to content

Commit b097efb

Browse files
Colin Ian Kingvinodkoul
authored andcommitted
drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
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: be28b65 ("drm/mediatek: separate hdmi phy to different file") Signed-off-by: Colin Ian King <colin.king@canonical.com> 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 <vkoul@kernel.org>
1 parent 1dfd7b7 commit b097efb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/phy/mediatek/phy-mtk-hdmi.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
8484
hdmi_phy->conf->hdmi_phy_disable_tmds)
8585
return &mtk_hdmi_phy_dev_ops;
8686

87-
dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
88-
return NULL;
87+
if (hdmi_phy)
88+
dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
89+
return NULL;
8990
}
9091

9192
static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,

0 commit comments

Comments
 (0)