Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3033858pxb; Mon, 18 Oct 2021 07:01:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykmQjX/rH7svn19dkHJ+r46+3rU70ssRw6ohNeTny9LM5yhes7faMX31HcEqyeetjejefU X-Received: by 2002:adf:ef4d:: with SMTP id c13mr35653747wrp.17.1634565690926; Mon, 18 Oct 2021 07:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565690; cv=none; d=google.com; s=arc-20160816; b=oiZH1ALytfKLsIfpP8+Fqk9oZwl/keqq4Tg3a519gk3dZv0mkQ8Cx5sm08NxRaJi0s jDRu9JskMOjyk519wImBg9U+yhdV0Yo1SXamBgTMM7su/Tua43G7PRtSUi2lewHGVFic rhZzFJAARadXZuMfnGSeo+7FwoBvwhL8NLuLAfMIVMIUom882ovTfeHyRVZh0lo0l+1a YTZVUfKVXBCEcV5LSF6xuwSc6sV7X3ebuT/wAdgqALjhsH7apc2S3t+cI9YsgvjdlmbI YCbgrXJOcm8I3opPyVMXlYgSCwPL0WCx1Az7jfMEd6B5vnUSZnqIOB9NEg3JhThvgsq4 zfnQ== 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=29Ko2Ev0k9ywCoRrKP0aQ+D1EPlEoT0xbvhLA0ykXos=; b=Dbv9ENGv7ikeMuHf/zwaLu5U3WgkOHO+CAKCmKKQoowrFo+fBx0fXYMUA+NEO24YyD +KCQN7aQw4PTRGFFE9IG+9JR64sAYtR9ydkXHdEtNsPEVkmJbutq5lbvCckjdgeI/o4I GBfj8Ofp4Nra1IxaBNJpkKlu7uwXSd7uOL2KSxJfDspIXhWYn9/xvTornd2VBx8aWdhH aplDCXIFO3rPZmwMXo0i1WHWhMb53Td48EDube/rZ2t4aGcGMs2X4L8tp9AW1VeFcD2w hLyu8dx52Ign7P9BDMCUyaKbeICAOhvn/EMNfPaJMqMvzPWYFPhqGyi48h8Ovo592o13 KNjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X2SM+PuL; 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 sd21si30687902ejc.727.2021.10.18.07.01.03; Mon, 18 Oct 2021 07:01:30 -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=X2SM+PuL; 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 S233638AbhJROA4 (ORCPT + 99 others); Mon, 18 Oct 2021 10:00:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:38968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233740AbhJRN7A (ORCPT ); Mon, 18 Oct 2021 09:59:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 207E361501; Mon, 18 Oct 2021 13:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564494; bh=vSKllmAoAxJEYAd7SNZSGjMWf2ruCZRmMu4m2CgWPNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X2SM+PuLD9Wb1f7nZbYzlC8YVmqOZz7pmPMlnAsSPFVV+pMhubsG6yZqcJU5oUwnF wAxDm7hGpSdRi4IwiW482rCyWTQ080g/W7+kkfDfakj058kjKrPjSj5Lr9neAo4ciS JaXqyQq020cdQ5x9K77zEOZIoY8PGYLWz93oZntc= 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.14 067/151] driver core: Reject pointless SYNC_STATE_ONLY device links Date: Mon, 18 Oct 2021 15:24:06 +0200 Message-Id: <20211018132342.869733806@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@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 @@ -675,7 +675,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_INFERRED) != DL_FLAG_SYNC_STATE_ONLY) ||