[PATCH 2/2] phy: marvell: Cannot test unsigned field to be negative

Stefan Roese stefan.roese at mailbox.org
Fri Aug 8 13:57:06 CEST 2025


On 06.08.25 18:43, Andrew Goodbody wrote:
> In comphy_cp110_init_serdes_map in comphy_cp110.c there are two fields
> in cfg, comphy_lanes_count and comphy_mux_bitcount, which are fetched
> from the FDT blob with fdtdec_get_int which returns an int. These two
> fields are then tested for being negative. However the fields are
> declared as unsigned so those tests must always fail. Change the
> declaration of those fields to be int instead of u32 and the code will
> work as expected.
> 
> This issue was found by Smatch.
> 
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>

Reviewed-by: Stefan Roese <stefan.roese at mailbox.org>

Thanks,
Stefan

> ---
>   drivers/phy/marvell/comphy_core.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/marvell/comphy_core.h b/drivers/phy/marvell/comphy_core.h
> index f3d04939387..086a4d82f26 100644
> --- a/drivers/phy/marvell/comphy_core.h
> +++ b/drivers/phy/marvell/comphy_core.h
> @@ -47,8 +47,8 @@ struct chip_serdes_phy_config {
>   	int (*rx_training)(struct chip_serdes_phy_config *, u32);
>   	void __iomem *comphy_base_addr;
>   	void __iomem *hpipe3_base_addr;
> -	u32 comphy_lanes_count;
> -	u32 comphy_mux_bitcount;
> +	int comphy_lanes_count;
> +	int comphy_mux_bitcount;
>   	const fdt32_t *comphy_mux_lane_order;
>   	u32 cp_index;
>   	struct comphy_map comphy_map_data[MAX_LANE_OPTIONS];
> 



More information about the U-Boot mailing list