The returned data for "vscsi-report-luns" is actually an array ofdisk
buffer-addr and buffer-len pairs. The expression "(args.table + 4 + 8 * i)"
is incorrect, in addition to being confusing. In addition, the list of
luns is not NULL-terminated, as implemented by the "while (*ptr)":
since the first reported LUN is likely to be "0" this loop ends up
processing no LUNs at all in most cases. The list of LUNs is terminated
according to length, not by a value.

Signed-off-by: Mukesh Kumar Chaurasiya <mchau...@linux.ibm.com>
---
 grub-core/disk/ieee1275/ofdisk.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
index c58a1fce8..eca447dc0 100644
--- a/grub-core/disk/ieee1275/ofdisk.c
+++ b/grub-core/disk/ieee1275/ofdisk.c
@@ -225,8 +225,12 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
        grub_ieee1275_cell_t table;
       }
       args;
+      struct lun_len {
+       grub_uint64_t *buf_adr;
+       grub_uint64_t buf_len;
+      } *tbl;
       char *buf, *bufptr;
-      unsigned i;
+      unsigned i, j;
 
       if (grub_ieee1275_open (alias->path, &ihandle))
        return;
@@ -251,12 +255,13 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
        return;
       bufptr = grub_stpcpy (buf, alias->path);
 
+      tbl = (struct lun_len *)args.table;
       for (i = 0; i < args.nentries; i++)
        {
          grub_uint64_t *ptr;
 
-         ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i);
-         while (*ptr)
+         ptr = (grub_uint64_t *)(grub_addr_t)tbl[i].buf_adr;
+         for (j = 0; j < tbl[i].buf_len; j++)
            {
              grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
              dev_iterate_real (buf, buf);
-- 
2.41.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to