On Fri, Feb 07, 2025 at 10:54:38AM +0800, Zijun Hu wrote: > On 2/7/2025 1:38 AM, Greg Kroah-Hartman wrote: > > +#include "base.h" > > + > > +#define MAX_FAUX_NAME_SIZE 256 /* Max size of a faux_device name */ > > Remove this macro? > > > ++ */ > > <snip> > > > +struct faux_device *faux_device_create_with_groups(const char *name, > > + const struct faux_device_ops *faux_ops, > > + const struct attribute_group **groups) > > +{ > > + struct device *dev; > > + struct faux_object *faux_obj; > > + struct faux_device *faux_dev; > > + int name_size; > > Remove @name_size? > > > + int ret; > > + > > + name_size = strlen(name); > > + if (name_size > MAX_FAUX_NAME_SIZE) > > + return NULL; > > + > > Remove above block related to @name_size > > > + faux_obj = kzalloc(sizeof(*faux_obj) + name_size + 1, GFP_KERNEL); > > faux_obj = kzalloc(sizeof(*faux_obj), GFP_KERNEL); Yes to all above, I forgot to rip that out when I dropped the name logic, good catch. > > ++int __init faux_bus_init(void) > > +{ > > + int ret; > > + > > + ret = device_register(&faux_bus_root); > > + if (ret) { > > + put_device(&faux_bus_root); > > + return ret; > > + } > > + > > + ret = bus_register(&faux_bus_type); > > + if (ret) > > + goto error_bus; > > + > > + ret = driver_register(&faux_driver); > > + if (ret) > > + goto error_driver; > > + > > + return ret; > > return 0; Nah, this is a common pattern, it's fine as-is. thanks, greg k-h