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

Commit 7908c801 authored by Mayank Rana's avatar Mayank Rana Committed by Vijayavardhan Vennapusa
Browse files

USB: android: Check ffs->state in ffs_ready_callback



In some cases race condition seen where adbd is being killed
and in parallel ffs_ready_callback() is executing.
ffs_ready_callback() checks config->enabled and tries to
re-enumerate selected USB composition. This USB composition
re-enumeration fails with error as:

ffs_function_bind_config(): usb_add_function() fails (err:-19) for ffs
android_bind_enabled_functions: ffs failed
android_enable: usb_add_config failed : err: -19
enable_store: enable_store: android_enable failed

Hence to avoid restarting of USB composition from ffs_ready_callaback()
if dev is NULL.

Change-Id: I92b7bf3e78ebcfe9195667229af67bc099ce0c9a
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent 0940fb6a
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -697,18 +697,17 @@ static int functionfs_ready_callback(struct ffs_data *ffs)
	struct android_dev *dev = ffs_function.android_dev;
	struct functionfs_config *config = ffs_function.config;

	if (dev)
		mutex_lock(&dev->mutex);
	if (!dev)
		return -ENODEV;

	mutex_lock(&dev->mutex);
	config->data = ffs;
	config->opened = true;

	if (config->enabled && dev)
		android_enable(dev);

	if (dev)
	mutex_unlock(&dev->mutex);

	return 0;
}