Re: [PATCH 1/4] firmware: qcom: tzmem: guard against IS_ERR() in the cleanup handler
From: Konrad Dybcio
Date: Thu Jul 02 2026 - 06:50:06 EST
On 7/2/26 10:10 AM, Mukesh Ojha wrote:
> On Wed, Jul 01, 2026 at 03:38:55PM +0200, Bartosz Golaszewski wrote:
>> We currently only silently skip NULL-pointers in the cleanup handler for
>> tzmem. It's possible that we get passed a pointer holding an ERR_PTR()
>> value so skip it too.
>>
>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
>> ---
>> include/linux/firmware/qcom/qcom_tzmem.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/linux/firmware/qcom/qcom_tzmem.h b/include/linux/firmware/qcom/qcom_tzmem.h
>> index 23173e0c3dddd154dd56dc3dcb56bd20ada0520a..b5520178bf6f53b86b530571a3be9f302225f022 100644
>> --- a/include/linux/firmware/qcom/qcom_tzmem.h
>> +++ b/include/linux/firmware/qcom/qcom_tzmem.h
>> @@ -58,7 +58,7 @@ devm_qcom_tzmem_pool_new(struct device *dev,
>> void *qcom_tzmem_alloc(struct qcom_tzmem_pool *pool, size_t size, gfp_t gfp);
>> void qcom_tzmem_free(void *ptr);
>>
>> -DEFINE_FREE(qcom_tzmem, void *, if (_T) qcom_tzmem_free(_T))
>> +DEFINE_FREE(qcom_tzmem, void *, if (!IS_ERR_OR_NULL(_T)) qcom_tzmem_free(_T))
>
> Is this really required? Are we trying to address an issue which
> does not exist today?
It doesn't, I was scratching my head too, but in patch 2 there's:
void *output_rt_tzm __free(qcom_tzmem) =
__qcom_scm_pas_get_rsc_table(ctx->pas_id, input_rt_tzm,
input_rt_size, &size);
and __qcom_scm_pas_get_rsc_table() does throw ERR_PTRs
Konrad