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. 8
      src/uboot_env.c

8
src/uboot_env.c

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

Loading…
Cancel
Save