summaryrefslogtreecommitdiff
path: root/drivers/serial/serial_msm_geni.c
diff options
context:
space:
mode:
authorAndrew Goodbody <andrew.goodbody@linaro.org>2025-08-11 18:03:39 +0100
committerCasey Connolly <casey.connolly@linaro.org>2025-08-13 15:17:36 +0200
commitf236451cb426fc3edaf756dac6346cd6273179b8 (patch)
treeb49a4288af7a750ec28d332c2c576058c0218a6b /drivers/serial/serial_msm_geni.c
parent23e1a11f4e8e3333ddcbff3bf88763c711340fe2 (diff)
serial: msm-geni: Detect error from get_clk_div_rate
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@linaro.org> Reviewed-by: Casey Connolly <casey.connolly@linaro.org> Link: https://lore.kernel.org/r/20250811-serial_msm_geni-v1-1-4499179491bc@linaro.org Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
Diffstat (limited to 'drivers/serial/serial_msm_geni.c')
-rw-r--r--drivers/serial/serial_msm_geni.c4
1 files changed, 4 insertions, 0 deletions
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);