diff mbox series

probe: Validate target class

Message ID 20180705144057.19781-1-hegdevasant@linux.vnet.ibm.com
State Accepted
Headers show
Series probe: Validate target class | expand

Commit Message

Vasant Hegde July 5, 2018, 2:40 p.m. UTC
Make sure target class is not NULL before comparision.

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
Note that this fixes Segfault issue. But I'm not sure why we endedup
having target->class = NULL. We may have real bug somehwere else in
the code.

-Vasant

 src/main.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Alistair Popple July 12, 2018, 5 a.m. UTC | #1
Thanks Vasant,

Looks to me to be the correct fix. The class gets filled in by matching
device-tree compatible properties, however I think it should be acceptable to
have device-tree entries which either don't match or don't have a valid class.

In your case I believe it was crashing because POWER9 NHTM support was removed
but not the corresponding device-tree entry. Hence there are device-tree entries
which need to be skipped because they don't match, and this is your patch does -
so thanks!

- Alistair

On Thursday, 5 July 2018 8:10:57 PM AEST Vasant Hegde wrote:
> Make sure target class is not NULL before comparision.
> 
> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
> ---
> Note that this fixes Segfault issue. But I'm not sure why we endedup
> having target->class = NULL. We may have real bug somehwere else in
> the code.
> 
> -Vasant
> 
>  src/main.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/main.c b/src/main.c
> index f89db2f..4c6b7fb 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -648,6 +648,10 @@ void print_target(struct pdbg_target *target, int level)
>  
>  	if (target) {
>  		char c = 0;
> +
> +		if (!pdbg_target_class_name(target))
> +			return;
> +
>  		if (!strcmp(pdbg_target_class_name(target), "pib"))
>  			c = 'p';
>  		else if (!strcmp(pdbg_target_class_name(target), "core"))
>
diff mbox series

Patch

diff --git a/src/main.c b/src/main.c
index f89db2f..4c6b7fb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -648,6 +648,10 @@  void print_target(struct pdbg_target *target, int level)
 
 	if (target) {
 		char c = 0;
+
+		if (!pdbg_target_class_name(target))
+			return;
+
 		if (!strcmp(pdbg_target_class_name(target), "pib"))
 			c = 'p';
 		else if (!strcmp(pdbg_target_class_name(target), "core"))