Skip to content

Commit be8ef91

Browse files
Saravana Kannangregkh
authored andcommitted
driver core: Reject pointless SYNC_STATE_ONLY device links
commit f729a59 upstream. SYNC_STATE_ONLY device links intentionally allow cycles because cyclic sync_state() dependencies are valid and necessary. However a SYNC_STATE_ONLY device link where the consumer and the supplier are the same device is pointless because the device link would be deleted as soon as the device probes (because it's also the consumer) and won't affect when the sync_state() callback is called. It's a waste of CPU cycles and memory to create this device link. So reject any attempts to create such a device link. Fixes: 05ef983 ("driver core: Add device link support for SYNC_STATE_ONLY flag") Cc: stable <stable@vger.kernel.org> Reported-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/r/20210929190549.860541-1-saravanak@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d5f13bb commit be8ef91

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/base/core.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ struct device_link *device_link_add(struct device *consumer,
549549
{
550550
struct device_link *link;
551551

552-
if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS ||
552+
if (!consumer || !supplier || consumer == supplier ||
553+
flags & ~DL_ADD_VALID_FLAGS ||
553554
(flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) ||
554555
(flags & DL_FLAG_SYNC_STATE_ONLY &&
555556
flags != DL_FLAG_SYNC_STATE_ONLY) ||

0 commit comments

Comments
 (0)