Message ID | 20191014022623.28475-1-alistair@popple.id.au |
---|---|
State | Accepted |
Headers | show |
Series | libpdbg: Fix segfault when auto-detecting host backend | expand |
On Mon, 2019-10-14 at 13:26 +1100, Alistair Popple wrote: > A NULL-dereference causes a segfault when running on the host with no > backend specified. Instead the backend should be auto-detected. > > Signed-off-by: Alistair Popple <alistair@popple.id.au> > --- > libpdbg/dtb.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c > index 53e9b73..c0fb374 100644 > --- a/libpdbg/dtb.c > +++ b/libpdbg/dtb.c > @@ -83,10 +83,12 @@ static void *ppc_target(void) > char line[256]; > FILE *cpuinfo; > > - if (!strcmp(pdbg_backend_option, "p8")) > - return &_binary_p8_host_dtb_o_start; > - else if (!strcmp(pdbg_backend_option, "p9")) > - return &_binary_p9_host_dtb_o_start; > + if (pdbg_backend_option) { > + if (!strcmp(pdbg_backend_option, "p8")) > + return &_binary_p8_host_dtb_o_start; > + else if (!strcmp(pdbg_backend_option, "p9")) > + return &_binary_p9_host_dtb_o_start; > + } > > cpuinfo = fopen("/proc/cpuinfo", "r"); > if (!cpuinfo) > -- > 2.20.1 > I have this fixed in my patch set. Are we ready to merge my patch set yet? Or do you want do another release with this fix before merging system device tree stuff? Amitay.
On Monday, 14 October 2019 4:12:34 PM AEDT Amitay Isaacs wrote: > On Mon, 2019-10-14 at 13:26 +1100, Alistair Popple wrote: > > A NULL-dereference causes a segfault when running on the host with no > > backend specified. Instead the backend should be auto-detected. > > > > Signed-off-by: Alistair Popple <alistair@popple.id.au> > > --- > > libpdbg/dtb.c | 10 ++++++---- > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c > > index 53e9b73..c0fb374 100644 > > --- a/libpdbg/dtb.c > > +++ b/libpdbg/dtb.c > > @@ -83,10 +83,12 @@ static void *ppc_target(void) > > char line[256]; > > FILE *cpuinfo; > > > > - if (!strcmp(pdbg_backend_option, "p8")) > > - return &_binary_p8_host_dtb_o_start; > > - else if (!strcmp(pdbg_backend_option, "p9")) > > - return &_binary_p9_host_dtb_o_start; > > + if (pdbg_backend_option) { > > + if (!strcmp(pdbg_backend_option, "p8")) > > + return &_binary_p8_host_dtb_o_start; > > + else if (!strcmp(pdbg_backend_option, "p9")) > > + return &_binary_p9_host_dtb_o_start; > > + } > > > > cpuinfo = fopen("/proc/cpuinfo", "r"); > > if (!cpuinfo) > > I have this fixed in my patch set. Are we ready to merge my patch set > yet? Or do you want do another release with this fix before merging > system device tree stuff? Yeah, this basically breaks the host so I was going to push this later today along with another minor fix for ecmd prior to merging the devtree stuff. - Alistair > Amitay. >
diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 53e9b73..c0fb374 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -83,10 +83,12 @@ static void *ppc_target(void) char line[256]; FILE *cpuinfo; - if (!strcmp(pdbg_backend_option, "p8")) - return &_binary_p8_host_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9")) - return &_binary_p9_host_dtb_o_start; + if (pdbg_backend_option) { + if (!strcmp(pdbg_backend_option, "p8")) + return &_binary_p8_host_dtb_o_start; + else if (!strcmp(pdbg_backend_option, "p9")) + return &_binary_p9_host_dtb_o_start; + } cpuinfo = fopen("/proc/cpuinfo", "r"); if (!cpuinfo)
A NULL-dereference causes a segfault when running on the host with no backend specified. Instead the backend should be auto-detected. Signed-off-by: Alistair Popple <alistair@popple.id.au> --- libpdbg/dtb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)