@@ -849,13 +849,11 @@ static int cpia2_usb_probe(struct usb_interface *intf,
if (ret < 0) {
ERR("%s: usb_set_interface error (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto free_data;
}
if((ret = cpia2_init_camera(cam)) < 0) {
ERR("%s: failed to initialize cpia2 camera (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto free_data;
}
LOG(" CPiA Version: %d.%02d (%d.%d)\n",
@@ -877,9 +875,12 @@ static int cpia2_usb_probe(struct usb_interface *intf,
if (ret < 0) {
ERR("%s: Failed to register cpia2 camera (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto free_data;
}
return 0;
+
+free_data:
+ kfree(cam);
+ return ret;
}