firmware: arm_scmi: prevent accessing rate_discrete uninitialized
gcc-5.3 and earlier warns that rate_discrete maybe-uninitialized
../drivers/firmware/arm_scmi/clock.c:185:5: warning: 'rate_discrete'
may be used uninitialized in this function [-Wmaybe-uninitialized]
if (rate_discrete)
^
../drivers/firmware/arm_scmi/clock.c:128:7: note:
'rate_discrete' was declared here
bool rate_discrete;
^
This patch fixing the warning by initialising rate_discrete and also using
goto label for the error path.
Fixes: 5f6c6430e9
("firmware: arm_scmi: add initial support for clock protocol")
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
[sudeep.holla: added one line description to the commit message]
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
parent
c09880cef7
commit
b5e817dcdd
|
@ -125,7 +125,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
|
||||||
{
|
{
|
||||||
u64 *rate;
|
u64 *rate;
|
||||||
int ret, cnt;
|
int ret, cnt;
|
||||||
bool rate_discrete;
|
bool rate_discrete = false;
|
||||||
u32 tot_rate_cnt = 0, rates_flag;
|
u32 tot_rate_cnt = 0, rates_flag;
|
||||||
u16 num_returned, num_remaining;
|
u16 num_returned, num_remaining;
|
||||||
struct scmi_xfer *t;
|
struct scmi_xfer *t;
|
||||||
|
@ -147,7 +147,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
|
||||||
|
|
||||||
ret = scmi_do_xfer(handle, t);
|
ret = scmi_do_xfer(handle, t);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
goto err;
|
||||||
|
|
||||||
rates_flag = le32_to_cpu(rlist->num_rates_flags);
|
rates_flag = le32_to_cpu(rlist->num_rates_flags);
|
||||||
num_remaining = NUM_REMAINING(rates_flag);
|
num_remaining = NUM_REMAINING(rates_flag);
|
||||||
|
@ -185,6 +185,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
|
||||||
if (rate_discrete)
|
if (rate_discrete)
|
||||||
clk->list.num_rates = tot_rate_cnt;
|
clk->list.num_rates = tot_rate_cnt;
|
||||||
|
|
||||||
|
err:
|
||||||
scmi_one_xfer_put(handle, t);
|
scmi_one_xfer_put(handle, t);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue