[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191125161313.GA1157@bogus>
Date: Mon, 25 Nov 2019 16:13:31 +0000
From: Sudeep Holla <sudeep.holla@....com>
To: Wen Yang <wenyang@...ux.alibaba.com>
Cc: Arnd Bergmann <arnd@...db.de>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Sudeep Holla <sudeep.holla@....com>
Subject: Re: [PATCH] firmware: arm_scmi: avoid double free in error flow
On Mon, Nov 25, 2019 at 11:54:09PM +0800, Wen Yang wrote:
> If device_register() fails, both put_device() and kfree()
> are called, ending with a double free of the scmi_dev.
>
Correct.
> Calling kfree() is needed only when a failure happens between the
> allocation of the scmi_dev and its registration, so move it to
> there and remove it from the error flow.
>
kstrdup_const can fail and in that case device is not yet registered,
so we need to free. Since device_register() calls put_device() on failure
too, I would just drop it as it's unnecessary, not sure why I have added
it in the first place. Can you re-spin the patch dropping put_device
and renaming put_dev label to something like free_const.
--
Regards,
Sudeep
Powered by blists - more mailing lists