Messages in this thread | | | From | Wei Fang <> | Subject | RE: [PATCH net-next] net: fec: Convert fec driver to use lock guards | Date | Wed, 8 May 2024 02:41:22 +0000 |
| |
> -----Original Message----- > From: Eric Dumazet <edumazet@google.com> > Sent: 2024年5月7日 18:40 > To: Wei Fang <wei.fang@nxp.com> > Cc: davem@davemloft.net; kuba@kernel.org; pabeni@redhat.com; Shenwei > Wang <shenwei.wang@nxp.com>; Clark Wang <xiaoning.wang@nxp.com>; > richardcochran@gmail.com; netdev@vger.kernel.org; > linux-kernel@vger.kernel.org; imx@lists.linux.dev > Subject: Re: [PATCH net-next] net: fec: Convert fec driver to use lock guards > > On Tue, May 7, 2024 at 11:16 AM Wei Fang <wei.fang@nxp.com> wrote: > > > > Use guard() and scoped_guard() defined in linux/cleanup.h to automate > > lock lifetime control in fec driver. > > > > Signed-off-by: Wei Fang <wei.fang@nxp.com> > > > > To me, this looks like a nice recipe for future disasters when doing backports, > because I am pretty sure the "goto ..." that assumes the lock is magically > released will fail horribly. > > I would use scoped_guard() only for new code.
Now that the kernel already supports scope-based resource management, I think we should actively use this new mechanism. At least the result could be safer resource management in the kernel and a lot fewer gotos.
| |