Re: [PATCH v2] driver: tx2: Add NULL check in tx2_uncore_pmu_register

From: Markus Elfring
Date: Mon Mar 31 2025 - 10:35:18 EST



> +++ b/drivers/perf/thunderx2_pmu.c
> @@ -738,7 +738,8 @@ static int tx2_uncore_pmu_register(
>
> tx2_pmu->pmu.name = devm_kasprintf(dev, GFP_KERNEL,
> "%s", name);
> -
> + if (!tx2_pmu->pmu.name)
> + return -ENOMEM;
> return perf_pmu_register(&tx2_pmu->pmu, tx2_pmu->pmu.name, -1);
> }


Should source code analysis approaches take further implementation details
better into account?

Example:
perf_pmu_register()
https://elixir.bootlin.com/linux/v6.14-rc6/source/kernel/events/core.c#L11859-L11862

if (WARN_ONCE(!name, "Can not register anonymous pmu.\n")) {
ret = -EINVAL;



Regards,
Markus