Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3023624pxb; Mon, 18 Oct 2021 06:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmxNFrcohZWTj002XlQ9OMQO2xpTWtfzmom7gX7ljY4njZ+s+bMQfd+ny+If4aOF/sXcoa X-Received: by 2002:a63:f306:: with SMTP id l6mr23431483pgh.72.1634564930995; Mon, 18 Oct 2021 06:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564930; cv=none; d=google.com; s=arc-20160816; b=cSEWAU7pEQTEQxb+VTMF9v1KSm1MjafhcEJ73ZEgXDQvWe+dET9AkLk/Twts6VdYt8 glt6uaw9KdPa+NO7oX2mrxe7aFYlui0k0zDqCF4nEw8gKq+gkXpw3yI2BKz350hssDov ltnhkwzghRtWaQI0DxTYuvRDcYNJ6R5MbGoxX+BuaTpf2NaP4W0YFxyXJufM+pD1+3iE EdqmvfpYcuQ6QrwYRDK4jzbaRmFNSUq37gOqOnKCFXK4C15s2Sd/wu+byqdFYiP4LfZ5 y6EvHgxQ1ncYftfLsxm7zpmJ/qtjMMdVQ/I4TsGXPDmmdR4GbnB5s0VeTIvevWXiecfG 6Uvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8eSbmLEP/ZH7jwKwIP4k4ZYAPi1uHnXV9oH7jpYxFhc=; b=LI4CzJJFi/GarI5/+Y470YGaJWJ3ROLCnoUQykRBShnnRdujQk8n0l3tByJriEzdij seAlikOWae6w004tMfQDsX/2VdLREjYx5gXENARK9UXuXYpjNMdeSrMM3s8b0nyyPM+w c2Rfuds7HR43xNTlUMzhtbp6bXS/H+6MhlrH/EiojbQYaKlydF5LjuT7b0UHzDshN5up JTzCER+fFdYGr2st6HH2G06DpiBTqpKNTFFU1XWy80Rp1DbQZv28aEYhAJVSyu/3WwUb siTocush0HTpemFWtRsuIpgng8Tb0JAqxMNLsMLROtof8FGvRx/8XSGNHbnpevDLbxRY O+XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cW+jqD0k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j70si3973793pgd.123.2021.10.18.06.48.38; Mon, 18 Oct 2021 06:48:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cW+jqD0k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232871AbhJRNso (ORCPT + 99 others); Mon, 18 Oct 2021 09:48:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233802AbhJRNpy (ORCPT ); Mon, 18 Oct 2021 09:45:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BBD1A615A7; Mon, 18 Oct 2021 13:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564149; bh=UKDdUxN31Y2tH8koy/hpWWmQl4c59XphxhJdnBYZU/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cW+jqD0kv9YG78cuViZYpjEiJdJg4DeH1NWt6LrIaRaNzf9NWbatELFXVZWSdk6Ff IyC32ovY2X5+lPqsYOVpJcxohqIthTPXtAh7CiZgnDhaEVibnAf1EdjU0lMPYmMrzg 9F/0cn+bbgIZnhdPAiSAXD6o4mDPkUOjA3h00dFY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ulf Hansson , "Rafael J. Wysocki" , Saravana Kannan Subject: [PATCH 5.10 050/103] driver core: Reject pointless SYNC_STATE_ONLY device links Date: Mon, 18 Oct 2021 15:24:26 +0200 Message-Id: <20211018132336.434618524@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132334.702559133@linuxfoundation.org> References: <20211018132334.702559133@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Saravana Kannan commit f729a592adb6760013c3e48622a5bf256b992452 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: 05ef983e0d65 ("driver core: Add device link support for SYNC_STATE_ONLY flag") Cc: stable Reported-by: Ulf Hansson Reviewed-by: Rafael J. Wysocki Reviewed-by: Ulf Hansson Signed-off-by: Saravana Kannan Link: https://lore.kernel.org/r/20210929190549.860541-1-saravanak@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -549,7 +549,8 @@ struct device_link *device_link_add(stru { struct device_link *link; - if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS || + if (!consumer || !supplier || consumer == supplier || + flags & ~DL_ADD_VALID_FLAGS || (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) || (flags & DL_FLAG_SYNC_STATE_ONLY && flags != DL_FLAG_SYNC_STATE_ONLY) ||