}
data_buf = memdup_user(buf, n_bytes);
- if (PTR_ERR(data_buf))
- return PTR_ERR(data_buf);
+ if (PTR_ERR(data_buf)) {
+ retval = PTR_ERR(data_buf);
+ goto exit;
+ }
memcpy(context->tx.data_buf, data_buf, n_bytes);
if (lirc_minor < 0) {
err("%s: lirc_register_driver failed", __func__);
alloc_status = 7;
- mutex_unlock(&context->ctx_lock);
+ retval = lirc_minor;
+ goto unlock;
} else
printk(KERN_INFO "%s: Registered Sasem driver (minor:%d)\n",
__func__, lirc_minor);
context = NULL;
case 1:
retval = -ENOMEM;
- goto exit;
+ goto unlock;
}
/* Needed while unregistering! */
printk(KERN_INFO "%s: Sasem device on usb<%d:%d> initialized\n",
__func__, dev->bus->busnum, dev->devnum);
-
+unlock:
mutex_unlock(&context->ctx_lock);
exit:
return retval;