[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87v9red5x7.fsf@ashishki-desk.ger.corp.intel.com>
Date: Wed, 20 Nov 2019 15:38:12 +0200
From: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
To: Wen Yang <wenyang@...ux.alibaba.com>
Cc: zhiche.yy@...baba-inc.com, xlpang@...ux.alibaba.com,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org, alexander.shishkin@...ux.intel.com
Subject: Re: [PATCH] intel_th: avoid double free in error flow
Wen Yang <wenyang@...ux.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
Powered by blists - more mailing lists