[PATCH 1/2] coresight: tmc: register the crash data interface only on probe success

Jie Gan jie.gan at oss.qualcomm.com
Mon Nov 30 16:52:58 PST 2026



On 11/30/2026 6:49 PM, Suzuki K Poulose wrote:
> On 30/11/2026 09:22, Jie Gan wrote:
>> The crash data interface is registered after the out label of
>> __tmc_probe(), which every error path jumps to. When the probe fails
>> while the reserved regions hold valid crash data,
>> is_tmc_crashdata_valid() and tmc_prepare_crashdata() log through
>> drvdata->csdev, which is then NULL, an error pointer or an unregistered
>> device, and register_crash_dev_interface() can register a misc device
>> whose driver data is freed when the probe failure is unwound.
>>
>> Only register the crash data interface once the probe has succeeded.
>>
>> Fixes: d58a70bdab57 ("coresight: tmc: Add support for reading crash 
>> data")
>> Reported-by: Sashiko <sashiko-bot at kernel.org>
>> Closes: https://sashiko.dev/#/bug/linux-f23df7b7- 
>> bae5-4fa0-96ef-4e83632058e8
>> Signed-off-by: Jie Gan <jie.gan at oss.qualcomm.com>
>> ---
>>   drivers/hwtracing/coresight/coresight-tmc-core.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/ 
>> drivers/hwtracing/coresight/coresight-tmc-core.c
>> index 0ef4b817b297..754a9b10b7d2 100644
>> --- a/drivers/hwtracing/coresight/coresight-tmc-core.c
>> +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
>> @@ -880,10 +880,10 @@ static int __tmc_probe(struct device *dev, 
>> struct resource *res)
>>           goto out;
>>       }
>> -out:
>>       if (is_tmc_crashdata_valid(drvdata) &&
>>           !tmc_prepare_crashdata(drvdata))
>>           register_crash_dev_interface(drvdata, desc.name);
>> +out:
>>       return ret;
>>   }
>>
> 
> 
> Goto for retuning just the error code, doesn't look like a good 
> practice. Please could we fix all goto out with return ?
> 
> See:
> 
> "The goto statement comes in handy when a function exits from multiple
> locations and some common work such as cleanup has to be done. *If there
> is no cleanup needed then just return directly.*"
> 

Acked and noted.

Thanks,
Jie

> 
> https://www.kernel.org/doc/html/latest/process/coding- 
> style.html#centralized-exiting-of-functions
> 
> Cheers
> Suzuki
> 
> 




More information about the linux-arm-kernel mailing list