dmraid_nvidia: Fix division by 0 and missing byte-swap.
This commit is contained in:
parent
94f701a826
commit
f76c98b79e
1 changed files with 9 additions and 4 deletions
|
@ -99,6 +99,8 @@ grub_dmraid_nv_detect (grub_disk_t disk,
|
||||||
struct grub_nv_super sb;
|
struct grub_nv_super sb;
|
||||||
int level;
|
int level;
|
||||||
grub_uint64_t disk_size;
|
grub_uint64_t disk_size;
|
||||||
|
grub_uint32_t capacity;
|
||||||
|
grub_uint8_t total_volumes;
|
||||||
char *uuid;
|
char *uuid;
|
||||||
|
|
||||||
if (disk->partition)
|
if (disk->partition)
|
||||||
|
@ -124,14 +126,17 @@ grub_dmraid_nv_detect (grub_disk_t disk,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
capacity = grub_le_to_cpu32 (sb.capacity);
|
||||||
|
total_volumes = sb.array.total_volumes;
|
||||||
|
|
||||||
switch (sb.array.raid_level)
|
switch (sb.array.raid_level)
|
||||||
{
|
{
|
||||||
case NV_LEVEL_0:
|
case NV_LEVEL_0:
|
||||||
level = 0;
|
level = 0;
|
||||||
disk_size = sb.capacity / sb.array.total_volumes;
|
if (total_volumes == 0)
|
||||||
if (sb.array.total_volumes == 0)
|
|
||||||
/* Not RAID. */
|
/* Not RAID. */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
disk_size = capacity / total_volumes;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NV_LEVEL_1:
|
case NV_LEVEL_1:
|
||||||
|
@ -141,10 +146,10 @@ grub_dmraid_nv_detect (grub_disk_t disk,
|
||||||
|
|
||||||
case NV_LEVEL_5:
|
case NV_LEVEL_5:
|
||||||
level = 5;
|
level = 5;
|
||||||
disk_size = sb.capacity / (sb.array.total_volumes - 1);
|
if (total_volumes == 0 || total_volumes == 1)
|
||||||
if (sb.array.total_volumes == 0 || sb.array.total_volumes == 1)
|
|
||||||
/* Not RAID. */
|
/* Not RAID. */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
disk_size = capacity / (total_volumes - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue