Message ID | 20200115051901.17514-13-amitay@ozlabs.org |
---|---|
State | Accepted |
Headers | show |
Series | Use fdt properties directly | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | warning | Failed to apply on branch master (8b4611b5d8e7e2279fe4aa80c892fcfe10aa398d) |
snowpatch_ozlabs/apply_patch | fail | Failed to apply to any branch |
Reviewed-by: Alistair Popple <alistair@popple.id.au> On Wednesday, 15 January 2020 4:19:00 PM AEDT Amitay Isaacs wrote: > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> > --- > libpdbg/device.c | 3 +++ > libpdbg/dtb.c | 20 ++++++++++++++++++++ > libpdbg/target.h | 1 + > 3 files changed, 24 insertions(+) > > diff --git a/libpdbg/device.c b/libpdbg/device.c > index 6c11836..f1c1f6b 100644 > --- a/libpdbg/device.c > +++ b/libpdbg/device.c > @@ -327,6 +327,9 @@ bool pdbg_target_set_property(struct pdbg_target > *target, const char *name, cons size_t len; > int ret; > > + if (!target->fdt || !pdbg_fdt_is_writeable(target->fdt)) > + return false; > + > p = pdbg_target_property(target, name, &len); > if (!p) > return false; > diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c > index 6fdce00..6e05663 100644 > --- a/libpdbg/dtb.c > +++ b/libpdbg/dtb.c > @@ -411,6 +411,26 @@ void *pdbg_system_fdt(void) > return pdbg_dtb.system.fdt; > } > > +static bool is_fdt_mapped(void *fdt, struct pdbg_mfile *mfile) > +{ > + if (mfile->fdt == fdt && mfile->fd != -1 && mfile->len != -1) { > + return true; > + } > + > + return false; > +} > + > +bool pdbg_fdt_is_writeable(void *fdt) > +{ > + bool ok; > + > + ok = is_fdt_mapped(fdt, &pdbg_dtb.system); > + if (!ok) > + ok = is_fdt_mapped(fdt, &pdbg_dtb.backend); > + > + return ok; > +} > + > static void close_dtb(struct pdbg_mfile *mfile) > { > if (mfile->fd != -1 && mfile->len != -1 && mfile->fdt) { > diff --git a/libpdbg/target.h b/libpdbg/target.h > index 1c08363..2ecdfce 100644 > --- a/libpdbg/target.h > +++ b/libpdbg/target.h > @@ -79,6 +79,7 @@ extern struct list_head target_classes; > > struct pdbg_dtb *pdbg_default_dtb(void *system_fdt); > const char *pdbg_get_backend_option(void); > +bool pdbg_fdt_is_writeable(void *fdt); > > struct chipop *pib_to_chipop(struct pdbg_target *target); > bool target_is_virtual(struct pdbg_target *target);
diff --git a/libpdbg/device.c b/libpdbg/device.c index 6c11836..f1c1f6b 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -327,6 +327,9 @@ bool pdbg_target_set_property(struct pdbg_target *target, const char *name, cons size_t len; int ret; + if (!target->fdt || !pdbg_fdt_is_writeable(target->fdt)) + return false; + p = pdbg_target_property(target, name, &len); if (!p) return false; diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 6fdce00..6e05663 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -411,6 +411,26 @@ void *pdbg_system_fdt(void) return pdbg_dtb.system.fdt; } +static bool is_fdt_mapped(void *fdt, struct pdbg_mfile *mfile) +{ + if (mfile->fdt == fdt && mfile->fd != -1 && mfile->len != -1) { + return true; + } + + return false; +} + +bool pdbg_fdt_is_writeable(void *fdt) +{ + bool ok; + + ok = is_fdt_mapped(fdt, &pdbg_dtb.system); + if (!ok) + ok = is_fdt_mapped(fdt, &pdbg_dtb.backend); + + return ok; +} + static void close_dtb(struct pdbg_mfile *mfile) { if (mfile->fd != -1 && mfile->len != -1 && mfile->fdt) { diff --git a/libpdbg/target.h b/libpdbg/target.h index 1c08363..2ecdfce 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -79,6 +79,7 @@ extern struct list_head target_classes; struct pdbg_dtb *pdbg_default_dtb(void *system_fdt); const char *pdbg_get_backend_option(void); +bool pdbg_fdt_is_writeable(void *fdt); struct chipop *pib_to_chipop(struct pdbg_target *target); bool target_is_virtual(struct pdbg_target *target);
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> --- libpdbg/device.c | 3 +++ libpdbg/dtb.c | 20 ++++++++++++++++++++ libpdbg/target.h | 1 + 3 files changed, 24 insertions(+)