Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4654584ybl; Mon, 26 Aug 2019 13:50:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuy+uUOYUfRqU3n93ZTS5YBSOwXqFQjsaSPtWTs4kxmPjBGKGdyBt1SrRyuvpbh1YuBXXM X-Received: by 2002:a17:902:f213:: with SMTP id gn19mr21011945plb.152.1566852646249; Mon, 26 Aug 2019 13:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566852646; cv=none; d=google.com; s=arc-20160816; b=FocH+H0uPszamsnmtBeyaabdifJgI+2rcTjvRYCW2NrD4PNdYFNP2CMbKkm+pcapRg g0qd2u8GaVgBw/OIiefaeNdevFLAAlcEgHyM0uy0i42Wp79tqTo+exUsCA5rjW7zn0aA ppIa6RiiYPKQiaXT2xi/l1ZrTybgkJsGpmi0Ay4yFkauqz8L46khnfBAV7oJd/NlcCNO AYy0VCozX/BNr8rYTleSFDOuoB1E7wC6D9OfVFraTOTdSMTmjkK3HPKakyIEM3Uu7Y1T MlJlV8Icquut8a+LWpewxDktmqR4GM+K645ph0juwmuPXBPdppiaAEPErEMDx6kiMaou i60A== 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:date:subject:cc:to:from; bh=DM4SIYG7sQTEjOqB8F7lxXgNafGIFwkWnaSKivSY4xs=; b=pitobh8f/FU+hn/aITDlxTqVtunlqN+n1KNJFlpY5tZh1NdxFIKEHmcZwnFkbwMeGc +DHlewO+gXX4DIvY0h7GoTQ/BaYgaVTSRnKRGfLFBJAYyrF4Cwa2gAjsZ0IeCYa/W57i 7mqC6rz9xf4PWlSFTHuL965COv15po4xiAhe2AIOoOfPN+3ICUKVkXtCKxOvqOveDK0w JrfJB+NH2qPLkTsVEg/tVI8IHL7zA+sCjiVWaJzjvqwnXEJju5hnncTaf7sty0x1fw6C 7xxW5ZkWGhKWH7K7XPluFEo++D1fh52HWpoal9jjHlLvpK4qSY2p8rbTcZFGlaiiD8my IMcA== 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=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a186si9708711pge.365.2019.08.26.13.50.30; Mon, 26 Aug 2019 13:50:46 -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; 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=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728989AbfHZUlf (ORCPT + 99 others); Mon, 26 Aug 2019 16:41:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:37881 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727205AbfHZUle (ORCPT ); Mon, 26 Aug 2019 16:41:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from parav@mellanox.com) with ESMTPS (AES256-SHA encrypted); 26 Aug 2019 23:41:32 +0300 Received: from sw-mtx-036.mtx.labs.mlnx (sw-mtx-036.mtx.labs.mlnx [10.12.150.149]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7QKfPDQ021168; Mon, 26 Aug 2019 23:41:30 +0300 From: Parav Pandit To: alex.williamson@redhat.com, jiri@mellanox.com, kwankhede@nvidia.com, cohuck@redhat.com, davem@davemloft.net Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Parav Pandit Subject: [PATCH 2/4] mdev: Make mdev alias unique among all mdevs Date: Mon, 26 Aug 2019 15:41:17 -0500 Message-Id: <20190826204119.54386-3-parav@mellanox.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190826204119.54386-1-parav@mellanox.com> References: <20190826204119.54386-1-parav@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mdev alias should be unique among all the mdevs, so that when such alias is used by the mdev users to derive other objects, there is no collision in a given system. Signed-off-by: Parav Pandit --- drivers/vfio/mdev/mdev_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index e825ff38b037..6eb37f0c6369 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -375,6 +375,11 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, ret = -EEXIST; goto mdev_fail; } + if (tmp->alias && strcmp(tmp->alias, alias) == 0) { + mutex_unlock(&mdev_list_lock); + ret = -EEXIST; + goto mdev_fail; + } } mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); -- 2.19.2