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.
Unified · Split
| @@ -225,9 +225,8 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph, · 224 unmodified lines | ||
| 225 | 225 | |
| 226 | 226 | /* Retrieve domain attributes at first ... */ |
| 227 | 227 | put_unaligned_le32(dom, td->tx.buf); |
| 228 | − ret = ph->xops->do_xfer(ph, td); | |
| 229 | 228 | /* Skip domain on comms error */ |
| 230 | − if (ret) | |
| 229 | + if (ph->xops->do_xfer(ph, td)) | |
| 231 | 230 | continue; |
| 232 | 231 | |
| 233 | 232 | v = vinfo->domains + dom; |
| @@ -249,12 +248,8 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph, · 15 unmodified lines | ||
| 249 | 248 | v->async_level_set = true; |
| 250 | 249 | } |
| 251 | 250 | |
| 252 | − ret = scmi_voltage_levels_get(ph, v); | |
| 253 | 251 | /* 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); | |
| 258 | 253 | } |
| 259 | 254 | |
| 260 | 255 | ph->xops->xfer_put(ph, td); |