ANDROID: usb: gadget: android_f_accessory: remove sleeping function from
spinlock misc_register function can sleep the execution and code shouldn't sleep in the atomic context. Move misc_register out of spinlock. use GFP_ATOMIC flag in memory allocation so the code context shouldn't go into sleep mode. Test: manually tested the above steps, and successfully switch between USB modes. Test: Run AOA verifier tool Bug: 322732675 Signed-off-by: Ashish Kumar Gupta <kumarashishg@google.com> (cherry picked from https://android-review.googlesource.com/q/commit:71a9b4bd904095839bdf986af71afd80c2fcb899) Merged-In: I9cd059a23d710cfd809add5801e85df17d55f6f7 Change-Id: I9cd059a23d710cfd809add5801e85df17d55f6f7
This commit is contained in:
committed by
Neill Kapron
parent
79c4b2fb58
commit
6514821bfe
@@ -1261,7 +1261,7 @@ static int acc_init(void)
|
||||
spin_unlock_irqrestore(&acc_dev_instance_lock, flags);
|
||||
return -EBUSY;
|
||||
}
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
dev = kzalloc(sizeof(*dev), GFP_ATOMIC);
|
||||
if (!dev) {
|
||||
spin_unlock_irqrestore(&acc_dev_instance_lock, flags);
|
||||
return -ENOMEM;
|
||||
@@ -1279,18 +1279,18 @@ static int acc_init(void)
|
||||
INIT_WORK(&dev->getprotocol_work, acc_getprotocol_work);
|
||||
INIT_WORK(&dev->sendstring_work, acc_sendstring_work);
|
||||
|
||||
kref_init(&dev->kref);
|
||||
acc_dev_instance = dev;
|
||||
spin_unlock_irqrestore(&acc_dev_instance_lock, flags);
|
||||
|
||||
ret = misc_register(&acc_device);
|
||||
if (ret)
|
||||
goto err_free_dev;
|
||||
|
||||
kref_init(&dev->kref);
|
||||
acc_dev_instance = dev;
|
||||
spin_unlock_irqrestore(&acc_dev_instance_lock, flags);
|
||||
return 0;
|
||||
|
||||
err_free_dev:
|
||||
kfree(dev);
|
||||
spin_unlock_irqrestore(&acc_dev_instance_lock, flags);
|
||||
pr_err("USB accessory gadget driver failed to initialize\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user