- if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0) {
- fsg_free(fsg);
- return rc;
- }
- set_bit(REGISTERED, &fsg->atomic_bitflags);
-
- /* Register the LUN devices and their attribute files */
- for (i = 0; i < fsg->nluns; ++i) {
- curlun = &fsg->luns[i];
- if ((rc = device_register(&curlun->dev)) != 0)
- INFO(fsg, "failed to register LUN%d: %d\n", i, rc);
- else {
- curlun->registered = 1;
- curlun->dev.release = lun_release;
- device_create_file(&curlun->dev, &dev_attr_ro);
- device_create_file(&curlun->dev, &dev_attr_file);
- }
- }
-
- /* Tell the thread to start working */
- complete(&fsg->thread_notifier);
- return 0;
+ if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0)
+ kref_put(&fsg->ref, fsg_release);
+ return rc;