From: Wen Yang <wenyang@linux.alibaba.com>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: zhiche.yy@alibaba-inc.com, xlpang@linux.alibaba.com,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] intel_th: avoid double free in error flow
Date: Wed, 20 Nov 2019 21:46:00 +0800 [thread overview]
Message-ID: <08c38d22-196d-a12e-f3e1-bc67f5912cb5@linux.alibaba.com> (raw)
In-Reply-To: <87v9red5x7.fsf@ashishki-desk.ger.corp.intel.com>
On 2019/11/20 9:38 下午, Alexander Shishkin wrote:
> Wen Yang <wenyang@linux.alibaba.com> writes:
>
>> Another example after a few lines lower:
>>
>> err = device_add(&thdev->dev);
>>
>> if (err) {
>> put_device(&thdev->dev);
>> goto fail_free_res;
>>
>> }
>>
>> 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.
>>
>> So the code in this place is correct.
> No, device_add() drops its own extra reference in case of error (as it
> should), so in "if (err) ..." branch we still only have just one
> reference before it goes free.
>
> Regards,
> --
> Alex
Well, ok, you are right.
We just checked the code and device_add() does release the reference count.
Thank you.
--
Regards,
Wen
prev parent reply other threads:[~2019-11-20 13:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 17:34 [PATCH] intel_th: avoid double free in error flow Wen Yang
2019-11-20 13:06 ` Alexander Shishkin
2019-11-20 13:31 ` Wen Yang
2019-11-20 13:38 ` Alexander Shishkin
2019-11-20 13:46 ` Wen Yang [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=08c38d22-196d-a12e-f3e1-bc67f5912cb5@linux.alibaba.com \
--to=wenyang@linux.alibaba.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xlpang@linux.alibaba.com \
--cc=zhiche.yy@alibaba-inc.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).