Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp740160imj; Thu, 7 Feb 2019 11:05:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IazSE7N1++giHBtEj7rJvnv49sdMNTmCRbPZd/FhEDpRPym/xZOfCtFSZxeQWevKBOtNYxW X-Received: by 2002:a63:287:: with SMTP id 129mr16141166pgc.332.1549566309073; Thu, 07 Feb 2019 11:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549566309; cv=none; d=google.com; s=arc-20160816; b=gdmvXKXwr4gx4GPSBexKwARo84RuAxXHfVS90cNpmygbB2XLOr4MGiSbV1HsAprsYg Ca2RuaZ3v1GqtdxZMnRIaOt7MWQIXHPIAmQ2fwhCv9gsDKfu6Qon/7OJtCcOrcaqJ75/ UKz9lWiZQXElo0ZFqfp5nDL0VzH88RGXLSsoTI4l3wJtmomiQ/RbEz6D0eBr8yc2/frE qz4IK5S8g0sdN67vPJ15zQ13idM/FPni9W1eXaosfJYdCXHxds0YPCfddcnGkRuGsxJb h2yROUA4DGvRQ1bbDDlPtZWsNxhW8CWNbf1qe7Qc1W2t7jlRVcMIAUoTKuNu/jfKKwoc pCoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=VnauLVLmjPTWnV0x3veHoPQAuU7AYv2A+vbP9nUnuJo=; b=lWlrHZ/Lgk0UPajSQhM3bL8NTCe1mHaWB8yCF/OL8dstpv+u/zsPgkfihJXHs1/pmr 190O/2uZxRcjAOhmkPsa5uZkwmBFpjnOfy7/X6vMhN2bNWEajUSc9bY1+3lOrGnYX3OV WJtn0Gm7sI4BQpiqnzeSokb+alcBeQfsQpKYkkuopfAq7N2+sdkeDTlIL4k96BFsnknB lakdDG7iiOCE7O/ssFVh+qCNjARhVkmQcFqv4JJ1JixaUW9tE7zNlLdozAESC3nekx4U XEHsZIOj+p66kWwvli9xzJRo26gPLwTLYl8mmCkV8QcurLi4cnF6BkECETbFVKqdyBGR 58FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si3188906pla.58.2019.02.07.11.04.47; Thu, 07 Feb 2019 11:05:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727039AbfBGTD3 (ORCPT + 99 others); Thu, 7 Feb 2019 14:03:29 -0500 Received: from bmailout3.hostsharing.net ([176.9.242.62]:55439 "EHLO bmailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbfBGTD3 (ORCPT ); Thu, 7 Feb 2019 14:03:29 -0500 Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id 82463100B07E1; Thu, 7 Feb 2019 20:03:26 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 39E8F8372B; Thu, 7 Feb 2019 20:03:26 +0100 (CET) Date: Thu, 7 Feb 2019 20:03:26 +0100 From: Lukas Wunner To: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman , LKML , Linux PM , Ulf Hansson , Daniel Vetter , Andrzej Hajda , Russell King - ARM Linux , Lucas Stach , Linus Walleij , Thierry Reding , Laurent Pinchart , Marek Szyprowski , Joerg Roedel Subject: Re: [PATCH v2 2/9] driver core: Avoid careless re-use of existing device links Message-ID: <20190207190326.wjxnzo4ja62t3mt6@wunner.de> References: <1952449.TVsm6CJCTy@aspire.rjw.lan> <2222273.ydJmd408XJ@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2222273.ydJmd408XJ@aspire.rjw.lan> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry, late to the party. On Fri, Feb 01, 2019 at 01:46:54AM +0100, Rafael J. Wysocki wrote: > After commit ead18c23c263 ("driver core: Introduce device links > reference counting"), if there is a link between the given supplier > and the given consumer already, device_link_add() will refcount it > and return it unconditionally. However, if the flags passed to > it on the second (or any subsequent) attempt to create a device > link between the same consumer-supplier pair are not compatible with > the existing link's flags, that is incorrect. Prior to ead18c23c263, a second invocation of device_link_add() also returned the existing device link without checking for incompatible flags. Hence this issue was not introduced by ead18c23c263, but rather by 9ed9895370ae ("driver core: Functional dependencies tracking support"), i.e. it was present all along. (Unless I'm missing something.) > Moreover, if the DL_FLAG_AUTOREMOVE_CONSUMER flag is passed to > device_link_add(), its caller will expect its reference to the link > to be dropped automatically on consumer driver removal, which will > not happen if that flag is not set in the link's flags (and > analogously for DL_FLAG_AUTOREMOVE_SUPPLIER). For this reason, make > device_link_add() update the existing link's flags accordingly > before returning it to the caller. Same here. > Fixes: ead18c23c263 ("driver core: Introduce device links reference counting") Should rather be Fixes: 9ed9895370ae ("driver core: Functional dependencies tracking support") (Again, unless I'm missing something.) Thanks, Lukas