diff --git a/ChangeLog b/ChangeLog index 45db5ffb3..3e34a478c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-01-14 Vladimir Serbinenko + + * grub-core/fs/zfs/zfs.c (grub_zfs_read): Remove useless alloc and + handle NULL appropriately. + Remove MIN. + 2012-01-13 Vladimir Serbinenko Fix efiemu. diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 534b7d224..782563384 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -3509,14 +3509,6 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) grub_size_t read; grub_err_t err; - if (data->file_buf == NULL) - { - data->file_buf = grub_malloc (SPA_MAXBLOCKSIZE); - if (!data->file_buf) - return -1; - data->file_start = data->file_end = 0; - } - /* * If offset is in memory, move it into the buffer provided and return. */ @@ -3553,12 +3545,18 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) 0, data); data->file_buf = t; if (err) - return -1; + { + data->file_buf = NULL; + data->file_start = data->file_end = 0; + return -1; + } data->file_start = blkid * blksz; data->file_end = data->file_start + blksz; - movesize = MIN (length, data->file_end - file->offset - read); + movesize = data->file_end - file->offset - read; + if (movesize > length) + movesize = length; grub_memmove (buf, data->file_buf + file->offset + read - data->file_start, movesize);