diff options
| author | Simon Glass <[email protected]> | 2025-03-15 14:25:59 +0000 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-04-03 11:43:22 -0600 |
| commit | 199648bac156daaaad1c66c52dcd33250a272e69 (patch) | |
| tree | a940eb331fac2c38417da848319482194f1aeba4 /boot/bootdev-uclass.c | |
| parent | 6acb0d28b06c408740e8b80e4015e1e656c7faf4 (diff) | |
boot: Handle running out of labels
If only a single label is provided in the list, bootdev_next_label()
does not operate correctly and reads beyond the end of the pointer list.
Fix this by adding a new check. Also add a note to convert this array
to an alist
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'boot/bootdev-uclass.c')
| -rw-r--r-- | boot/bootdev-uclass.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 9e4c3db2dc1..3791ebfcb42 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -579,6 +579,9 @@ int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp, struct udevice *dev; log_debug("next\n"); + if (iter->cur_label >= 0 && !iter->labels[iter->cur_label]) + return log_msg_ret("fil", -ENODEV); + for (dev = NULL; !dev && iter->labels[++iter->cur_label];) { const char *label = iter->labels[iter->cur_label]; int ret; |
