Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp750681imj; Thu, 7 Feb 2019 11:13:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ5wPdWn1ou0tuDmdMA/NxleyfLfhhv/bp6m/dOdXEhyNAQVODu6CTSSfCVU684QE4iI5t9 X-Received: by 2002:a17:902:166:: with SMTP id 93mr18213599plb.20.1549566822342; Thu, 07 Feb 2019 11:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549566822; cv=none; d=google.com; s=arc-20160816; b=DamoMDqk1Z3dj+IfUOa8oSXcJ8Xw4lXCm949y4BGeKkfp3TwNWgwknrPKoJk4QyvKD DqPyhr1O4cXa7/npsDXgo2dZj2OpqQfcqQdbYt/Zi2cgwtZ+X8WQNlwszPls0Dko9ict Uk6t2NVSjSS9DWCn6Mv3DhoM/fFhwksmxcTxz39vdHVIAWOR2zNX0kXfI47cfNRboe/b dSfAeB6pRqi7UhhuJnROhOo6B+KZG3ovYY7yoRgAXPGM9DNsuplkzZDb2NolaOAZAauS 2BFb1ZXzDHtkxs8uHx8E4wlDpM4IpoWFfXN8HuKCpY0nxadUhDxvawpMKAS16R1Vx9ZY vyIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=RJG72g6Kf3jio022jxa9wuXY7Jt/DK1D0lRKNRKikTg=; b=VSoRxRZ5NOvRyQBR15pdBFKbevssc7ebyRIScA3HGWv2xNqwZPM/p+1JIk7ICLveE6 KSiEWFoI9hoMnVZTUNpRHasz0Ebge0Rweqv5OJwwLV+17/zI+ERyrYnhQV+FePxqPdBX bM8aCqYzNDL/hQ4sNmNWqHffwLTdLUr0MCk4qt9tGLwl2SRNfO2vUPXI9loWqq8K/euO HOuOlsw9UjH8fU4FIYswD++EVrCX6A142UE2EpukSIcFjKkdm8VYKhYWhuSGl7DU2LQa sEEfLckvzfvn0TGB/h+/BPG01tT/5ezAwz9HyNVEElQg1s8hFtt4lzLZ3Aml7rOWLvEM a23g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r29si9571959pga.477.2019.02.07.11.13.25; Thu, 07 Feb 2019 11:13:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727248AbfBGTLX (ORCPT + 99 others); Thu, 7 Feb 2019 14:11:23 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:33608 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbfBGTLW (ORCPT ); Thu, 7 Feb 2019 14:11:22 -0500 Received: by mail-ot1-f66.google.com with SMTP id i20so1794724otl.0; Thu, 07 Feb 2019 11:11:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RJG72g6Kf3jio022jxa9wuXY7Jt/DK1D0lRKNRKikTg=; b=AwnStN8V6Yw68od8fAETmyqO9IQSLi51IaB/Ql2EuIJ7s/pNtbb+GtV/3d0wT/8z4J W44WHx8u4Wy9snNI85wY641+HjL05qEN1Iz/hbOU2W32yBR+X8PvPsX4jfP4QIM6r1q9 qQnnNR56hq4vSRbBxo2QCM8TK5fGpG6kkeNdYShdZ2RMsrzSijfH4dmZicfh6ElEqX7A qPN0l97Kaevt7dLJqGV6OZfN2a/6Kd7qc9o/1OBWe8Q4USuhYMyeNduDrgQSgpDpn+7K DsIe8DN9nRy7QglRrx4XeJpmnNiMZBMyKBB1nD9xIXD1DUfwOzR5fRCpcLygPsygsEYI CHdA== X-Gm-Message-State: AHQUAubcBVHPK0Z5Q7OUaapgjHcGDh9CDmlRW/YO0X+bUXYuzrID8N3j FKxrrfivIt8ABgl/6gGTfUDJkr+rrl6zsmb4GV8= X-Received: by 2002:aca:3d42:: with SMTP id k63mr1175161oia.95.1549566681008; Thu, 07 Feb 2019 11:11:21 -0800 (PST) MIME-Version: 1.0 References: <1952449.TVsm6CJCTy@aspire.rjw.lan> <2222273.ydJmd408XJ@aspire.rjw.lan> <20190207190326.wjxnzo4ja62t3mt6@wunner.de> In-Reply-To: <20190207190326.wjxnzo4ja62t3mt6@wunner.de> From: "Rafael J. Wysocki" Date: Thu, 7 Feb 2019 20:11:10 +0100 Message-ID: Subject: Re: [PATCH v2 2/9] driver core: Avoid careless re-use of existing device links To: Lukas Wunner Cc: "Rafael J. Wysocki" , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 7, 2019 at 8:03 PM Lukas Wunner wrote: > > 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.) I haven't checked far enough into the past, sorry about that. You are right, but actually I think that Fixes: 9ed9895370ae ("driver core: Functional dependencies tracking support") should be there in addition to the other Fixes: tag, because the issue is still present after that commit and the patch does not apply directly on top of 9ed9895370ae.