Skip to content

Commit 44dbdf3

Browse files
ludvigpasudeep-holla
authored andcommitted
firmware: arm_scmi: Fix incorrect error propagation in scmi_voltage_descriptors_get
scmi_voltage_descriptors_get() will incorrecly return an error code if the last iteration of the for loop that retrieves the descriptors is skipped due to an error. Skipping an iteration in the loop is not an error, but the `ret` value from the last iteration will be propagated when the function returns. Fix by not saving return values that should not be propagated. This solution also minimizes the risk of future patches accidentally re-introducing this bug. Link: https://lore.kernel.org/r/20220610140055.31491-1-ludvig.parsson@axis.com Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Ludvig Pärsson <ludvig.parsson@axis.com> [sudeep.holla: Removed unneeded reset_rx_to_maxsz and check for return value from scmi_voltage_levels_get as suggested by Cristian] Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
1 parent 4314f9f commit 44dbdf3

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

drivers/firmware/arm_scmi/voltage.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,8 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph,
225225

226226
/* Retrieve domain attributes at first ... */
227227
put_unaligned_le32(dom, td->tx.buf);
228-
ret = ph->xops->do_xfer(ph, td);
229228
/* Skip domain on comms error */
230-
if (ret)
229+
if (ph->xops->do_xfer(ph, td))
231230
continue;
232231

233232
v = vinfo->domains + dom;
@@ -249,12 +248,8 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph,
249248
v->async_level_set = true;
250249
}
251250

252-
ret = scmi_voltage_levels_get(ph, v);
253251
/* Skip invalid voltage descriptors */
254-
if (ret)
255-
continue;
256-
257-
ph->xops->reset_rx_to_maxsz(ph, td);
252+
scmi_voltage_levels_get(ph, v);
258253
}
259254

260255
ph->xops->xfer_put(ph, td);

0 commit comments

Comments
 (0)