From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 1/6] omap3isp: Don't rely on devm for memory resource management
Date: Tue, 28 Feb 2017 15:12:39 +0200 [thread overview]
Message-ID: <17312150.yLXnxzLeiM@avalon> (raw)
In-Reply-To: <1487604142-27610-2-git-send-email-sakari.ailus@linux.intel.com>
Hi Sakari,
Thank you for the patch.
On Monday 20 Feb 2017 17:22:17 Sakari Ailus wrote:
> devm functions are fine for managing resources that are directly related
> to the device at hand and that have no other dependencies. However, a
> process holding a file handle to a device created by a driver for a device
> may result in the file handle left behind after the device is long gone.
> This will result in accessing released (and potentially reallocated)
> memory.
>
> Instead, manage the memory resources in the driver. Releasing the
> resources can be later on bound to e.g. by releasing a reference.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> drivers/media/platform/omap3isp/isp.c | 18 ++++++++++++------
> drivers/media/platform/omap3isp/isph3a_aewb.c | 24 +++++++++++++++++-------
> drivers/media/platform/omap3isp/isph3a_af.c | 24 +++++++++++++++++-------
> drivers/media/platform/omap3isp/isphist.c | 11 +++++++----
> drivers/media/platform/omap3isp/ispstat.c | 2 ++
> 5 files changed, 55 insertions(+), 24 deletions(-)
[snip]
> diff --git a/drivers/media/platform/omap3isp/isphist.c
> b/drivers/media/platform/omap3isp/isphist.c index a4ed5d1..9e448c6 100644
> --- a/drivers/media/platform/omap3isp/isphist.c
> +++ b/drivers/media/platform/omap3isp/isphist.c
> @@ -476,9 +476,9 @@ int omap3isp_hist_init(struct isp_device *isp)
> {
> struct ispstat *hist = &isp->isp_hist;
> struct omap3isp_hist_config *hist_cfg;
> - int ret = -1;
> + int ret;
>
> - hist_cfg = devm_kzalloc(isp->dev, sizeof(*hist_cfg), GFP_KERNEL);
> + hist_cfg = kzalloc(sizeof(*hist_cfg), GFP_KERNEL);
> if (hist_cfg == NULL)
> return -ENOMEM;
>
> @@ -500,7 +500,7 @@ int omap3isp_hist_init(struct isp_device *isp)
> if (IS_ERR(hist->dma_ch)) {
> ret = PTR_ERR(hist->dma_ch);
> if (ret == -EPROBE_DEFER)
> - return ret;
> + goto err;
>
> hist->dma_ch = NULL;
> dev_warn(isp->dev,
> @@ -516,9 +516,12 @@ int omap3isp_hist_init(struct isp_device *isp)
> hist->event_type = V4L2_EVENT_OMAP3ISP_HIST;
>
> ret = omap3isp_stat_init(hist, "histogram", &hist_subdev_ops);
> +
> +err:
> if (ret) {
> - if (hist->dma_ch)
> + if (!IS_ERR(hist->dma_ch))
I think this change is wrong. dma_ch is initialize to NULL by kzalloc(). You
will end up calling dma_release_channel() on a NULL channel if
omap3isp_stat_init() fails and HIST_CONFIG_DMA is false. The check should be
if (!IS_ERR_OR_NULL(hist->dma_ch))
Apart from that,
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> dma_release_channel(hist->dma_ch);
> + kfree(hist_cfg);
> }
>
> return ret;
[snip]
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2017-02-28 13:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-20 15:22 [PATCH 0/6] Media controller and omap3isp cleanups Sakari Ailus
2017-02-20 15:22 ` [PATCH 1/6] omap3isp: Don't rely on devm for memory resource management Sakari Ailus
2017-02-28 13:12 ` Laurent Pinchart [this message]
2017-02-28 13:21 ` Sakari Ailus
2017-02-20 15:22 ` [PATCH 2/6] omap3isp: Call video_unregister_device() unconditionally Sakari Ailus
2017-02-28 13:42 ` Laurent Pinchart
2017-02-20 15:22 ` [PATCH 3/6] omap3isp: Remove misleading comment Sakari Ailus
2017-02-28 13:42 ` Laurent Pinchart
2017-02-20 15:22 ` [PATCH 4/6] omap3isp: Disable streaming at driver unbind time Sakari Ailus
2017-02-28 13:51 ` Laurent Pinchart
2017-02-28 14:00 ` Sakari Ailus
2017-02-28 14:53 ` Laurent Pinchart
2017-02-24 13:13 ` Sakari Ailus
2017-02-20 15:22 ` [PATCH 5/6] media: Remove useless curly braces and parentheses Sakari Ailus
2017-02-28 13:42 ` Laurent Pinchart
2017-02-20 15:22 ` [PATCH 6/6] media: devnode: Rename mdev argument as devnode Sakari Ailus
2017-02-28 13:42 ` Laurent Pinchart
2017-02-20 20:37 ` [PATCH 0/6] Media controller and omap3isp cleanups Hans Verkuil
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=17312150.yLXnxzLeiM@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.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