Re: [PATCH v6 4/4] soc: qcom: ubwc: Fix missing include

[email protected]
Newsgroups dev.linux.lists.imx
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing cleanup in `a5xx_gpu_init()` when `qcom_ubwc_config_get_data()` returns an error, leading to a memory and resource leak.
--

--- Patch [4]: [PATCH v6 4/4] soc: qcom: ubwc: Fix missing include ---
commit 8a6d2fb79b4edaad79d216dc3cc985d7cf39e314
Author: Daniel Baluta <[email protected]>

soc: qcom: ubwc: Fix missing include

This commit adds the <linux/err.h> include to ubwc.h to resolve a compilation
error regarding the implicit declaration of ERR_PTR when
CONFIG_QCOM_UBWC_CONFIG=n.

Fixes: 1924272b9ce1 ("soc: qcom: Add UBWC config provider")

> diff --git a/include/linux/soc/qcom/ubwc.h b/include/linux/soc/qcom/ubwc.h
> index a7372d9c25fbc..f3a70360b177b 100644
> --- a/include/linux/soc/qcom/ubwc.h
> +++ b/include/linux/soc/qcom/ubwc.h
> @@ -8,6 +8,7 @@
>  #define __QCOM_UBWC_H__
>  
>  #include <linux/bits.h>
> +#include <linux/err.h>

[Severity: High]
This isn't a bug introduced by this patch, but it brings attention to a
potential memory and resource leak in a5xx_gpu_init() when it calls
qcom_ubwc_config_get_data().

If qcom_ubwc_config_get_data() returns -EPROBE_DEFER (when SMEM is unavailable)
or -EOPNOTSUPP (when CONFIG_QCOM_UBWC_CONFIG=n), the function returns the error
directly without tearing down the initialized GPU resources via a5xx_destroy():

drivers/gpu/drm/msm/adreno/a5xx_gpu.c:a5xx_gpu_init() {
    ...
	/* Inherit the common config and make some necessary fixups */
	adreno_gpu->ubwc_config = qcom_ubwc_config_get_data();
	if (IS_ERR(adreno_gpu->ubwc_config))
		return ERR_CAST(adreno_gpu->ubwc_config);
    ...
}

Because qcom_ubwc_config_get_data() actively returns -EPROBE_DEFER when SMEM
isn't ready, this error path will be taken during standard boot sequences where
SMEM probes after the GPU.

Does this code leak the a5xx_gpu structure and ringbuffers initialized by
adreno_gpu_init() on each deferral?

>  #include <linux/printk.h>
>  #include <linux/types.h>
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.