History

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.

Ludvig Pärsson committed 4 years ago

Commit 44dbdf31 parent 4314f9f1 file · +2 −7Browse files

Unified · Split

drivers/firmware/arm_scmi/voltage.c+2−7
@@ -225,9 +225,8 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph, · 224 unmodified lines
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, · 15 unmodified lines
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);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t