From: Wen Yang <wenyang@linux.alibaba.com>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
stable@vger.kernel.org
Subject: Re: [GIT PULL 1/3] intel_th: Fix a double put_device() in error path
Date: Wed, 20 Nov 2019 21:36:46 +0800 [thread overview]
Message-ID: <2e648871-b7f7-c77e-6a22-3c26ad90633b@linux.alibaba.com> (raw)
In-Reply-To: <20191120130806.44028-2-alexander.shishkin@linux.intel.com>
On 2019/11/20 9:08 下午, Alexander Shishkin wrote:
> Commit a753bfcfdb1f ("intel_th: Make the switch allocate its subdevices")
> factored out intel_th_subdevice_alloc() from intel_th_populate(), but got
> the error path wrong, resulting in two instances of a double put_device()
> on a freshly initialized, but not 'added' device.
>
> Fix this by only doing one put_device() in the error path.
>
> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Fixes: a753bfcfdb1f ("intel_th: Make the switch allocate its subdevices")
> Reported-by: Wen Yang <wenyang@linux.alibaba.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: stable@vger.kernel.org # v4.14+
> ---
> drivers/hwtracing/intel_th/core.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
> index d5c1821b31c6..0dfd97bbde9e 100644
> --- a/drivers/hwtracing/intel_th/core.c
> +++ b/drivers/hwtracing/intel_th/core.c
> @@ -649,10 +649,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
> }
>
> err = intel_th_device_add_resources(thdev, res, subdev->nres);
> - if (err) {
> - put_device(&thdev->dev);
> + if (err)
> goto fail_put_device;
> - }
>
> if (subdev->type == INTEL_TH_OUTPUT) {
> if (subdev->mknode)
> @@ -667,10 +665,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
> }
>
> err = device_add(&thdev->dev);
> - if (err) {
> - put_device(&thdev->dev);
> + if (err)
> goto fail_free_res;
> - }
>
> /* need switch driver to be loaded to enumerate the rest */
> if (subdev->type == INTEL_TH_SWITCH && !req) {
device_add() has increased the reference count,
so when it returns an error, an additional call to put_device()
is needed here to reduce the reference count.
--
Regards,
Wen
next prev parent reply other threads:[~2019-11-20 13:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 13:08 [GIT PULL 0/3] intel_th: Updates for v5.5 Alexander Shishkin
2019-11-20 13:08 ` [GIT PULL 1/3] intel_th: Fix a double put_device() in error path Alexander Shishkin
2019-11-20 13:36 ` Wen Yang [this message]
2019-11-20 13:44 ` Alexander Shishkin
2019-11-20 13:08 ` [GIT PULL 2/3] intel_th: pci: Add Ice Lake CPU support Alexander Shishkin
2019-11-20 13:08 ` [GIT PULL 3/3] intel_th: pci: Add Tiger " Alexander Shishkin
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=2e648871-b7f7-c77e-6a22-3c26ad90633b@linux.alibaba.com \
--to=wenyang@linux.alibaba.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).