Re: [PATCH 1/4] firmware: qcom: tzmem: guard against IS_ERR() in the cleanup handler
From: Mukesh Ojha
Date: Thu Jul 02 2026 - 07:19:07 EST
On Thu, Jul 02, 2026 at 04:47:51AM -0500, Bartosz Golaszewski wrote:
> On Thu, 2 Jul 2026 10:10:26 +0200, Mukesh Ojha
> <mukesh.ojha@xxxxxxxxxxxxxxxx> said:
> > 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 becomes needed in patch 2/4 where in qcom_scm_pas_get_rsc_table() the
> pointer returned by _qcom_scm_pas_get_rsc_table() can contain ERR_PTR() so
> this patch preempts a possible problem.
>
Yes, I see now. It was easy to get ignored in this cleanup.
Reviewed-by: Mukesh Ojha <mukesh.ojha@xxxxxxxxxxxxxxxx>
--
-Mukesh Ojha