Message ID | 20210110105324.10547-1-alex.kiernan@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [libubootenv] Correct initialisations in libuboot_configure | expand |
Hi Alex, On 10.01.21 11:53, Alex Kiernan wrote: > From: Alex Kiernan <alexk@zuma.ai> > > libuboot_configure() fails to initialise dev->offset from the envdevs > structure and also doesn't setup ctx->size as happens in > libuboot_read_config(); use the same logic as exists there. > > Signed-off-by: Alex Kiernan <alexk@zuma.ai> > Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> > --- > > src/uboot_env.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/src/uboot_env.c b/src/uboot_env.c > index 577721c25205..ec04f151bd3e 100644 > --- a/src/uboot_env.c > +++ b/src/uboot_env.c > @@ -1422,10 +1422,14 @@ int libuboot_configure(struct uboot_ctx *ctx, > break; > memset(dev->devname, 0, sizeof(dev->devname)); > strncpy(dev->devname, envdevs->devname, sizeof(dev->devname) - 1); > + dev->offset = envdevs->offset; Ouch...you are absolutely right. Thanks for the fix. > dev->envsize = envdevs->envsize; > dev->sectorsize = envdevs->sectorsize; > dev->envsectors = envdevs->envsectors; > > + if (!ctx->size) > + ctx->size = dev->envsize; > + > if (check_env_device(ctx, dev) < 0) > return -EINVAL; > > Acked-by : Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/src/uboot_env.c b/src/uboot_env.c index 577721c25205..ec04f151bd3e 100644 --- a/src/uboot_env.c +++ b/src/uboot_env.c @@ -1422,10 +1422,14 @@ int libuboot_configure(struct uboot_ctx *ctx, break; memset(dev->devname, 0, sizeof(dev->devname)); strncpy(dev->devname, envdevs->devname, sizeof(dev->devname) - 1); + dev->offset = envdevs->offset; dev->envsize = envdevs->envsize; dev->sectorsize = envdevs->sectorsize; dev->envsectors = envdevs->envsectors; + if (!ctx->size) + ctx->size = dev->envsize; + if (check_env_device(ctx, dev) < 0) return -EINVAL;