Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4721991ooa; Tue, 14 Aug 2018 09:39:23 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz125/FI11DcXJFU9Ktlylm3X4WiIOcP+ABKaB0ffpy/sRgUWKx6iJ7JU9rArKLmu4HL1XR X-Received: by 2002:a62:34c4:: with SMTP id b187-v6mr23843259pfa.15.1534264763695; Tue, 14 Aug 2018 09:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534264763; cv=none; d=google.com; s=arc-20160816; b=wz1L+wRFoAdCiSrtOAOPx9Bi/6H+C1PW2vb7/uImI9A3Ad6fViu7axR19Br/d+dBNZ FKlkdtaaxCeHHjYV/Fg5W8B1gtIpENmedsbvY6loEBsVUrrSQXWrTgcA4yww7T/QKzqL V61XxW4eOJWp/XtNUutfLCjlaTWpMUXonwwM1JGXSvEXNt3HnBvQAltB78vuT1/HLBua NfFLlYePa2LCqZDacVWH9k4/f2yMNDl4i+9zvyhcdk9+7dy1vrxtg2OuRpbwW1e93VdK RRqLqAesvqxxz8R+y0q8K/PIr67doKBjmblTiigusGIxyxTq19YaWn8ah1AHp3Z7zPR1 GEmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=ABONiHC0qSwiuKM5JoeYEvivOsqn8NYNPj94p+0qIEs=; b=YXjX9QnoQCQ9W7MUWEuy0UlwnofqdIytAcyqyiWkhEZePuLnMM3znU4raPszQTIx4c fhUnRaM/IAOqhdhIyxy4eFPHFcjG+Ioa0PHthlW2TTLCGs9CDBrtHFY0I+hNzHfSVOxO tD/WWQA+LKjh2wq+IKfIY16A/ZG0GDggq92xiEtudEqzN57eGQGzSOCBMc/LCR0U+yjM /FI79N3CHX5qv7y3vtJCxi0la0jrqu1lxenGiNxv1yyrDT2xwHScOoxd4B+l4t5RH5lT HW2ET0CZj6jqs1S0mRa6sKmIcSBAR+a6wJ+cQJV0Yf3wVNfS4AnZvp4MWHU2UqiuClju s0oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=VyfMTTOX; 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 6-v6si20514245pgv.508.2018.08.14.09.39.07; Tue, 14 Aug 2018 09:39:23 -0700 (PDT) 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; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=VyfMTTOX; 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 S1732686AbeHNTXK (ORCPT + 99 others); Tue, 14 Aug 2018 15:23:10 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36410 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732411AbeHNTXK (ORCPT ); Tue, 14 Aug 2018 15:23:10 -0400 Received: by mail-pg1-f193.google.com with SMTP id h12-v6so9346912pgs.3 for ; Tue, 14 Aug 2018 09:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ABONiHC0qSwiuKM5JoeYEvivOsqn8NYNPj94p+0qIEs=; b=VyfMTTOX5r7j99vA8nFLD5eDCXMN71E1UBTL3vnyzE6QIbX7B/wsawcknLtbJcr/GD yEdXzDwGkFHj4kNk185NMCNU6Jp8AOXcRhlSJsn2sDnyU2rpFxQW+gur8a+fQ/IHGoL/ 6I3cGQDJtJZPMzhkAwppSwzYQTOHrRYCpyI6E3ZYhl8P5ehtOUXrsIx9x2SzH69uvpmc 9mfDucZvjFUo8Pvwb19FYAK0IHdRgm+xXoHU5GmhiNhNN74ckkTu/5jk9xQh4YV0tv5Z FgpUpQKOQfbNDynudXqWiyzigkSRED+gZmptYLbQQmZQ2kGl0EpZcH7u+CRhCFLTyPxy IHfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ABONiHC0qSwiuKM5JoeYEvivOsqn8NYNPj94p+0qIEs=; b=qR0R9ECVd9pOjiM3mngdLbxLKu5JFDvqJsGBPJqiM4cA9bTWhYF7CyRbO6ei8Ax0SC yzqdPvDw+3rQSLQLSbrJznLe0WF6G35Jf+EgYhR9H+q6mQN8hU94sdjTqdsXhr4b1+cW xLZPohW3ZFMuQRIXPVrhL0MFhheghNkFgBQWSskLUVCFFHTL6LLP9jUdOo9h0OW9s/dM cagAxV9ljcDtAC61wsiMdSrBVoh6XVmjdE7ywiI4w1uZczVjVoIq9RH8KOsw6PRqJXuz kblO2SQ4Cw6Lu1WvW96OmDxSLEfHbSQ2TjOHRn4a9hIOP5s/6ngYbCxDfgDgN2rUOSaP 0A5w== X-Gm-Message-State: AOUpUlHmMSQM3Mahvx7epelZI8jzmBsIIu9PU11fyGqIYUSq15CAtEKb tklvGbKZQcruiBM5jX0TTfG4Hg== X-Received: by 2002:a65:4b87:: with SMTP id t7-v6mr21322125pgq.391.1534264517819; Tue, 14 Aug 2018 09:35:17 -0700 (PDT) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c88-v6sm30723525pfe.132.2018.08.14.09.35.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 09:35:17 -0700 (PDT) Date: Tue, 14 Aug 2018 09:35:14 -0700 From: Stephen Hemminger To: "Michael Kelley (EOSG)" Cc: KY Srinivasan , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , Stephen Hemminger , "vkuznets@redhat.com" Subject: Re: [PATCH 2/5] vmbus: add driver_override support Message-ID: <20180814093514.7febc8d5@xeon-e3> In-Reply-To: References: <20180810230520.2055-1-kys@linuxonhyperv.com> <20180810230611.2114-1-kys@linuxonhyperv.com> <20180810230611.2114-2-kys@linuxonhyperv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 Aug 2018 19:30:50 +0000 "Michael Kelley (EOSG)" wrote: > > +/* > > + * Return a matching hv_vmbus_device_id pointer. > > + * If there is no match, return NULL. > > + */ > > +static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv, > > + struct hv_device *dev) > > +{ > > + const uuid_le *guid = &dev->dev_type; > > + const struct hv_vmbus_device_id *id; > > > > - return NULL; > > + /* When driver_override is set, only bind to the matching driver */ > > + if (dev->driver_override && strcmp(dev->driver_override, drv->name)) > > + return NULL; > > This function needs to be covered by the device lock, so that > dev->driver_override can't be set to NULL and the memory freed > during the above 'if' statement. When called from vmbus_probe(), > the device lock is held, so it's good. But when called from > vmbus_match(), the device lock may not be held: consider the path > __driver_attach() -> driver_match_device() -> vmbus_match(). The function hv_vmbus_get_id is called from that path. i.e. __device_attach -> driver-match_device -> vmbus_match. and __device_attach always does: device_lock(dev); The code in driver _override_store uses the same device_lock when storing the new value. This is same locking as is done in pci-sysfs.c