[PATCH 1/2] serial: msm-geni: Detect error from get_clk_div_rate
Casey Connolly
casey.connolly at linaro.org
Wed Aug 13 15:16:49 CEST 2025
On 11/08/2025 19:03, Andrew Goodbody wrote:
> In msm_serial_setbrg if the call to get_clk_div_rate fails then there
> will not have been an assignment to clk_div which will lead to the call
> to geni_serial_baud using an uninitialised value.
> Check for an error from get_clk_div_rate and return an error code if so.
>
> This issue was found by Smatch.
>
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
Reviewed-by: Casey Connolly <casey.connolly at linaro.org>
Thanks Andrew!> ---
> drivers/serial/serial_msm_geni.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/serial/serial_msm_geni.c b/drivers/serial/serial_msm_geni.c
> index cb6c09fdd09..33016f0cb53 100644
> --- a/drivers/serial/serial_msm_geni.c
> +++ b/drivers/serial/serial_msm_geni.c
> @@ -252,6 +252,10 @@ static int msm_serial_setbrg(struct udevice *dev, int baud)
> priv->baud = baud;
>
> clk_rate = get_clk_div_rate(baud, priv->oversampling, &clk_div);
> + if (!clk_rate) {
> + pr_err("%s: Couldn't get clock division rate\n", __func__);
> + return -EINVAL;
> + }
> ret = geni_serial_set_clock_rate(dev, clk_rate);
> if (ret < 0) {
> pr_err("%s: Couldn't set clock rate: %d\n", __func__, ret);
>
--
// Casey (she/her)
More information about the U-Boot
mailing list