From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Yu Kuai <yukuai3@huawei.com>
Cc: kieran.bingham+renesas@ideasonboard.com, airlied@linux.ie,
daniel@ffwll.ch, dri-devel@lists.freedesktop.org,
linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@huawei.com
Subject: Re: [PATCH] drm: rcar-du: add missing put_device() call in rcar_du_vsp_init()
Date: Wed, 16 Sep 2020 02:30:04 +0300 [thread overview]
Message-ID: <20200915233004.GD14954@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20200910132354.692397-1-yukuai3@huawei.com>
Hi Yu,
Thank you for the patch.
On Thu, Sep 10, 2020 at 09:23:54PM +0800, Yu Kuai wrote:
> if of_find_device_by_node() succeed, rcar_du_vsp_init() doesn't have
> a corresponding put_device(). Thus add a jump target to fix the exception
> handling for this function implementation.
>
> Fixes: 6d62ef3ac30b ("drm: rcar-du: Expose the VSP1 compositor through KMS planes")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> index f1a81c9b184d..172ee3f3b21c 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> @@ -352,14 +352,16 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
>
> /* Find the VSP device and initialize it. */
> pdev = of_find_device_by_node(np);
> - if (!pdev)
> - return -ENXIO;
> + if (!pdev) {
> + ret = -ENXIO;
> + goto put_device;
> + }
This change isn't needed, and will actually cause a crash, as pdev is
NULL.
>
> vsp->vsp = &pdev->dev;
>
> ret = vsp1_du_init(vsp->vsp);
> if (ret < 0)
> - return ret;
> + goto put_device;
>
> /*
> * The VSP2D (Gen3) has 5 RPFs, but the VSP1D (Gen2) is limited to
> @@ -369,8 +371,10 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
>
> vsp->planes = devm_kcalloc(rcdu->dev, vsp->num_planes,
> sizeof(*vsp->planes), GFP_KERNEL);
> - if (!vsp->planes)
> - return -ENOMEM;
> + if (!vsp->planes) {
> + ret = -ENOMEM;
> + goto put_device;
> + }
>
> for (i = 0; i < vsp->num_planes; ++i) {
> enum drm_plane_type type = i < num_crtcs
> @@ -387,7 +391,7 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
> ARRAY_SIZE(rcar_du_vsp_formats),
> NULL, type, NULL);
> if (ret < 0)
> - return ret;
> + goto put_device;
>
> drm_plane_helper_add(&plane->plane,
> &rcar_du_vsp_plane_helper_funcs);
> @@ -403,4 +407,7 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
> }
>
> return 0;
I would add a blank line here.
> +put_device:
And maybe name the label "error" ?
> + put_device(&pdev->dev);
> + return ret;
> }
We need more than this, we also need to call put_device() when the
driver is unloaded. The way to handle cleanup in DRM is through
drmm_add_action() nowadays, and I think we could thus simply replace the
change above with a cleanup action that is run both in the error path
and at driver remove.
I'll post a proposal in a reply to this e-mail.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2020-09-15 23:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 13:23 [PATCH] drm: rcar-du: add missing put_device() call in rcar_du_vsp_init() Yu Kuai
2020-09-15 23:30 ` Laurent Pinchart [this message]
2020-09-15 23:38 ` [PATCH] drm: rcar-du: Put reference to VSP device Laurent Pinchart
2020-09-16 10:26 ` Kieran Bingham
2020-09-17 0:43 ` Laurent Pinchart
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=20200915233004.GD14954@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).