tracing/probes: Fix to add NULL check for BTF APIs

Since find_btf_func_param() abd btf_type_by_id() can return NULL,
the caller must check the return value correctly.

Link: https://lore.kernel.org/all/169024903951.395371.11361556840733470934.stgit@devnote2/

Fixes: b576e09701c7 ("tracing/probes: Support function parameters if BTF is available")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+4 -4
+4 -4
kernel/trace/trace_probe.c
··· 386 386 387 387 /* Get BTF_KIND_FUNC type */ 388 388 t = btf_type_by_id(btf, id); 389 - if (!btf_type_is_func(t)) 389 + if (!t || !btf_type_is_func(t)) 390 390 return ERR_PTR(-ENOENT); 391 391 392 392 /* The type of BTF_KIND_FUNC is BTF_KIND_FUNC_PROTO */ 393 393 t = btf_type_by_id(btf, t->type); 394 - if (!btf_type_is_func_proto(t)) 394 + if (!t || !btf_type_is_func_proto(t)) 395 395 return ERR_PTR(-ENOENT); 396 396 397 397 return t; ··· 443 443 if (!ctx->params) { 444 444 params = find_btf_func_param(ctx->funcname, &ctx->nr_params, 445 445 ctx->flags & TPARG_FL_TPOINT); 446 - if (IS_ERR(params)) { 446 + if (IS_ERR_OR_NULL(params)) { 447 447 trace_probe_log_err(ctx->offset, NO_BTF_ENTRY); 448 448 return PTR_ERR(params); 449 449 } ··· 1273 1273 1274 1274 params = find_btf_func_param(ctx->funcname, &nr_params, 1275 1275 ctx->flags & TPARG_FL_TPOINT); 1276 - if (IS_ERR(params)) { 1276 + if (IS_ERR_OR_NULL(params)) { 1277 1277 if (args_idx != -1) { 1278 1278 /* $arg* requires BTF info */ 1279 1279 trace_probe_log_err(0, NOSUP_BTFARG);