Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: ti: gmii-sel: check of_get_address() for failure

Smatch complains that if of_get_address() returns NULL, then "size"
isn't initialized. Also it would lead to an Oops.

Fixes: 7f78322cdd67 ("phy: ti: gmii-sel: retrieve ports number and base offset from dt")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Link: https://lore.kernel.org/r/20210914110038.GB11657@kili
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Dan Carpenter and committed by
Vinod Koul
8d55027f d8b951ab

+2
+2
drivers/phy/ti/phy-gmii-sel.c
··· 320 320 u64 size; 321 321 322 322 offset = of_get_address(dev->of_node, 0, &size, NULL); 323 + if (!offset) 324 + return -EINVAL; 323 325 priv->num_ports = size / sizeof(u32); 324 326 if (!priv->num_ports) 325 327 return -EINVAL;