Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56cf6cbf authored by Manu Gautam's avatar Manu Gautam Committed by Gerrit - the friendly Code Review server
Browse files

USB: f_accessory: Fix crash if driver failed to initialize



If accessory driver setup fails then _acc_dev points to
freed memory and later drivers crashes on disconnect
due to invalid memory access. Mark _acc_dev only if
acc_setup is successful to prevent the crash.

Change-Id: Ica933a7cf710ff082c54db77f94f802b6832bedb
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 347b9498
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1217,13 +1217,13 @@ static int acc_setup(void)
	INIT_DELAYED_WORK(&dev->start_work, acc_start_work);
	INIT_WORK(&dev->hid_work, acc_hid_work);

	/* _acc_dev must be set before calling usb_gadget_register_driver */
	_acc_dev = dev;

	ret = misc_register(&acc_device);
	if (ret)
		goto err;

	/* _acc_dev must be set before calling usb_gadget_register_driver */
	_acc_dev = dev;

	return 0;

err: