Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links

SYNC_STATE_ONLY device links only affect the behavior of sync_state()
callbacks. Specifically, they prevent sync_state() only callbacks from
being called on a device if one or more of its consumers haven't probed.

So, creating a SYNC_STATE_ONLY device link from an already probed
consumer is useless. So, don't allow creating such device links.

Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20201121020232.908850-10-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Saravana Kannan and committed by
Greg Kroah-Hartman
ac66c5bb 7b337cb3

+11
+11
drivers/base/core.c
··· 650 650 } 651 651 652 652 /* 653 + * SYNC_STATE_ONLY links are useless once a consumer device has probed. 654 + * So, only create it if the consumer hasn't probed yet. 655 + */ 656 + if (flags & DL_FLAG_SYNC_STATE_ONLY && 657 + consumer->links.status != DL_DEV_NO_DRIVER && 658 + consumer->links.status != DL_DEV_PROBING) { 659 + link = NULL; 660 + goto out; 661 + } 662 + 663 + /* 653 664 * DL_FLAG_AUTOREMOVE_SUPPLIER indicates that the link will be needed 654 665 * longer than for DL_FLAG_AUTOREMOVE_CONSUMER and setting them both 655 666 * together doesn't make sense, so prefer DL_FLAG_AUTOREMOVE_SUPPLIER.