[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221116135915.hvhbx6ik2g7bxeox@pengutronix.de>
Date:   Wed, 16 Nov 2022 14:59:15 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     linux-pwm@...r.kernel.org,
        Thierry Reding <thierry.reding@...il.com>,
        linux-kernel@...r.kernel.org, kernel@...gutronix.de
Subject: Re: [PATCH 3/4] pwm: Mark free pwm IDs as used in alloc_pwms()
On Wed, Nov 16, 2022 at 10:17:08AM +0200, Andy Shevchenko wrote:
> On Tue, Nov 15, 2022 at 10:15:14PM +0100, Uwe Kleine-König wrote:
> > alloc_pwms() only identified a free range of IDs and this range was marked
> > as used only later by pwmchip_add(). Instead let alloc_pwms() already do
> > the marking (which makes the function actually allocating the range and so
> > justifies the function name). This way access to the allocated_pwms
> > bitfield is limited to two functions only.
> 
> This change is a bit fragile in a long term. Currently we know that we have
> no points of error after alloc_pwms() in ->probe(), but if somebody misses
> this in the future, we became to the case where bitmap might be exhausted
> (kinda resource leakage).
That is always the case for a function allocating resources. If you add
an error path after the (previously) last allocation, you have to care
for that.
Best regards
Uwe
-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists