Re: [PATCH] clockevents: add a error handling in tick_broadcast_init_sysfs()

From: Haoxiang Li

Date: Fri Dec 19 2025 - 08:28:25 EST


On Fri, 19 Dec 2025 11:17:27 +0100, Thomas Gleixner wrote:
>On Thu, Dec 18 2025 at 17:06, Haoxiang Li wrote:
> > If device_register() fails, call put_device() to drop
> > the device reference.
> >
> > Fixes: 501f867064e9 ("clockevents: Provide sysfs interface")
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Haoxiang Li <lihaoxiang@xxxxxxxxxxxxxxxx>
> > ---
> > kernel/time/clockevents.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
> > index a59bc75ab7c5..94e223cf9c74 100644
> > --- a/kernel/time/clockevents.c
> > +++ b/kernel/time/clockevents.c
> > @@ -733,8 +733,12 @@ static __init int tick_broadcast_init_sysfs(void)
> > {
> > int err = device_register(&tick_bc_dev);
> >
> > - if (!err)
> > - err = device_create_file(&tick_bc_dev, &dev_attr_current_device);
> > + if (err) {
> > + put_deivce(&tick_bc_dev);
>
> My brain compiler tells me that this was not even compiled. Try again.

Sorry for my oversight. However, I found that tick_bc_dev is a static struct.
Is the error handling here pointless?