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/
Unified · Split
| @@ -386,12 +386,12 @@ static const struct btf_type *find_btf_func_proto(const char *funcname) · 385 unmodified lines | |||
| 386 | 386 | ||
| 387 | /* Get BTF_KIND_FUNC type */ | 387 | /* Get BTF_KIND_FUNC type */ |
| 388 | t = btf_type_by_id(btf, id); | 388 | t = btf_type_by_id(btf, id); |
| 389 | if (!btf_type_is_func(t)) | 389 | if (!t || !btf_type_is_func(t)) |
| 390 | return ERR_PTR(-ENOENT); | 390 | return ERR_PTR(-ENOENT); |
| 391 | 391 | ||
| 392 | /* The type of BTF_KIND_FUNC is BTF_KIND_FUNC_PROTO */ | 392 | /* The type of BTF_KIND_FUNC is BTF_KIND_FUNC_PROTO */ |
| 393 | t = btf_type_by_id(btf, t->type); | 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 | return ERR_PTR(-ENOENT); | 395 | return ERR_PTR(-ENOENT); |
| 396 | 396 | ||
| 397 | return t; | 397 | return t; |
| @@ -443,7 +443,7 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code, · 45 unmodified lines | |||
| 443 | if (!ctx->params) { | 443 | if (!ctx->params) { |
| 444 | params = find_btf_func_param(ctx->funcname, &ctx->nr_params, | 444 | params = find_btf_func_param(ctx->funcname, &ctx->nr_params, |
| 445 | ctx->flags & TPARG_FL_TPOINT); | 445 | ctx->flags & TPARG_FL_TPOINT); |
| 446 | if (IS_ERR(params)) { | 446 | if (IS_ERR_OR_NULL(params)) { |
| 447 | trace_probe_log_err(ctx->offset, NO_BTF_ENTRY); | 447 | trace_probe_log_err(ctx->offset, NO_BTF_ENTRY); |
| 448 | return PTR_ERR(params); | 448 | return PTR_ERR(params); |
| 449 | } | 449 | } |
| @@ -1273,7 +1273,7 @@ const char **traceprobe_expand_meta_args(int argc, const char *argv[], · 823 unmodified lines | |||
| 1273 | 1273 | ||
| 1274 | params = find_btf_func_param(ctx->funcname, &nr_params, | 1274 | params = find_btf_func_param(ctx->funcname, &nr_params, |
| 1275 | ctx->flags & TPARG_FL_TPOINT); | 1275 | ctx->flags & TPARG_FL_TPOINT); |
| 1276 | if (IS_ERR(params)) { | 1276 | if (IS_ERR_OR_NULL(params)) { |
| 1277 | if (args_idx != -1) { | 1277 | if (args_idx != -1) { |
| 1278 | /* $arg* requires BTF info */ | 1278 | /* $arg* requires BTF info */ |
| 1279 | trace_probe_log_err(0, NOSUP_BTFARG); | 1279 | trace_probe_log_err(0, NOSUP_BTFARG); |