From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>,
robdclark@gmail.com, quic_abhinavk@quicinc.com, sean@poorly.run,
airlied@gmail.com, sumit.semwal@linaro.org,
christian.koenig@amd.com
Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, freedreno@lists.freedesktop.org
Subject: Re: [PATCH RESEND] drm/msm: Add missing check and destroy for alloc_ordered_workqueue
Date: Mon, 9 Jan 2023 00:45:04 +0200 [thread overview]
Message-ID: <9b53d5f0-e1b1-1ecd-b9b9-efa20b11c916@linaro.org> (raw)
In-Reply-To: <20230106084712.29675-1-jiasheng@iscas.ac.cn>
On 06/01/2023 10:47, Jiasheng Jiang wrote:
> Add check for the return value of alloc_ordered_workqueue as it may return
> NULL pointer.
> Moreover, use the destroy_workqueue in the later fails in order to avoid
> memory leak.
>
> Fixes: c8afe684c95c ("drm/msm: basic KMS driver for snapdragon")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> drivers/gpu/drm/msm/msm_drv.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 8b0b0ac74a6f..b82d938226ad 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -418,6 +418,8 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
> priv->dev = ddev;
>
> priv->wq = alloc_ordered_workqueue("msm", 0);
> + if (!priv->wq)
> + return -ENOMEM;
>
> INIT_LIST_HEAD(&priv->objects);
> mutex_init(&priv->obj_lock);
> @@ -440,12 +442,12 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
>
> ret = msm_init_vram(ddev);
> if (ret)
> - return ret;
> + goto err_destroy_workqueue;
>
> /* Bind all our sub-components: */
> ret = component_bind_all(dev, ddev);
> if (ret)
> - return ret;
> + goto err_destroy_workqueue;
>
> dma_set_max_seg_size(dev, UINT_MAX);
>
> @@ -540,6 +542,8 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
>
> err_msm_uninit:
> msm_drm_uninit(dev);
return ret is missing here. Your code will result in double free.
However the intent was to unroll each and every action of msm_drm_init()
in msm_drm_uninit(). So in all your cases please goto err_msm_unit.
> +err_destroy_workqueue:
> + destroy_workqueue(priv->wq);
> return ret;
> }
>
--
With best wishes
Dmitry
prev parent reply other threads:[~2023-01-08 22:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-06 8:47 Jiasheng Jiang
2023-01-08 22:45 ` Dmitry Baryshkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b53d5f0-e1b1-1ecd-b9b9-efa20b11c916@linaro.org \
--to=dmitry.baryshkov@linaro.org \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jiasheng@iscas.ac.cn \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=quic_abhinavk@quicinc.com \
--cc=robdclark@gmail.com \
--cc=sean@poorly.run \
--cc=sumit.semwal@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®