aes3500: Fix possible crash if USB init fails

The code was indented, but only the first call was actually in the
conditional, which meant that initialisation carried on as normal on top
of a failed USB device. Exit early and remove the conditional to fix
this.
This commit is contained in:
Bastien Nocera 2016-11-05 00:11:30 +01:00
parent a0bbbd7d32
commit 8454a25ecf

View file

@ -130,15 +130,16 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
struct aes3k_dev *aesdev; struct aes3k_dev *aesdev;
r = libusb_claim_interface(dev->udev, 0); r = libusb_claim_interface(dev->udev, 0);
if (r < 0) if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r)); fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
aesdev = dev->priv = g_malloc0(sizeof(struct aes3k_dev)); aesdev = dev->priv = g_malloc0(sizeof(struct aes3k_dev));
if (!aesdev) if (!aesdev)
return -ENOMEM; return -ENOMEM;
if (r == 0)
aesdev->data_buflen = DATA_BUFLEN; aesdev->data_buflen = DATA_BUFLEN;
aesdev->frame_width = FRAME_WIDTH; aesdev->frame_width = FRAME_WIDTH;
aesdev->frame_size = FRAME_SIZE; aesdev->frame_size = FRAME_SIZE;