]> git.baikalelectronics.ru Git - kernel.git/commit
phy: sun4i-usb: fix dereference of pointer phy0 before it is null checked
authorColin Ian King <colin.king@canonical.com>
Thu, 25 Jun 2020 12:44:28 +0000 (13:44 +0100)
committerVinod Koul <vkoul@kernel.org>
Thu, 25 Jun 2020 12:55:37 +0000 (18:25 +0530)
commite0e2bb02d053b61c586626dab14926636cd25e77
tree5981089efc6cf32bfd2be7a21a9448b67445140c
parente37cfa51fa835b71de908fee89405cfa44865893
phy: sun4i-usb: fix dereference of pointer phy0 before it is null checked

Currently pointer phy0 is being dereferenced via the assignment of
phy on the call to phy_get_drvdata before phy0 is null checked, this
can lead to a null pointer dereference. Fix this by performing the
null check on phy0 before the call to phy_get_drvdata. Also replace
the phy0 == NULL check with the more usual !phy0 idiom.

Addresses-Coverity: ("Dereference before null check")
Fixes: 8503a85daa34 ("phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200625124428.83564-1-colin.king@canonical.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/allwinner/phy-sun4i-usb.c