From b5362f7c59d93cd7e7d9e85170e5ceb5341200e2 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Thu, 10 Jan 2019 12:18:31 -0800 Subject: [PATCH] Check if can_update_spt succeeded This fixes uninitialized value compiler warning for tseg1 and tseg2. --- can-calc-bit-timing.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c index 0293b45..4f19eb9 100644 --- a/can-calc-bit-timing.c +++ b/can-calc-bit-timing.c @@ -511,7 +511,11 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, /* real sample point */ bt->sample_point = can_update_spt(btc, spt_nominal, best_tseg, - &tseg1, &tseg2, NULL); + &tseg1, &tseg2, &spt_error); + if (spt_error == UINT_MAX) { + netdev_err(dev, "can_update_spt failed\n"); + return -EDOM; + } v64 = (u64)best_brp * 1000 * 1000 * 1000; do_div(v64, priv->clock.freq);