Browse Source

Fix bug introduced by commit 52a70114

The return value from lseek is not checked correctly, causing that the
environment is not read or written if an offset is set.

Signed-off-by: Stefano Babic <sbabic@denx.de>
pull/10/head
Stefano Babic 4 years ago
parent
commit
23b30860c1
  1. 12
      src/uboot_env.c

12
src/uboot_env.c

@ -403,8 +403,10 @@ static int fileread(struct uboot_flash_env *dev, void *data)
if (dev->offset)
ret = lseek(dev->fd, dev->offset, SEEK_SET);
if (!ret)
ret = read(dev->fd, data, dev->envsize);
if (ret < 0)
return ret;
ret = read(dev->fd, data, dev->envsize);
return ret;
}
@ -599,8 +601,10 @@ static int filewrite(struct uboot_flash_env *dev, void *data)
if (dev->offset)
ret = lseek(dev->fd, dev->offset, SEEK_SET);
if (!ret)
ret = write(dev->fd, data, dev->envsize);
if (ret < 0)
return ret;
ret = write(dev->fd, data, dev->envsize);
fileprotect(dev, true); // no error handling, keep ret from write

Loading…
Cancel
Save