Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3490575img; Mon, 25 Mar 2019 11:20:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyg9SQMM5n5O1V54I1n+CJzsSt7zoPRdTfxcn0JTQS6uMzxiliVPIIFufS+0jRgNNDh8LWk X-Received: by 2002:a63:af06:: with SMTP id w6mr24188857pge.338.1553538005632; Mon, 25 Mar 2019 11:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553538005; cv=none; d=google.com; s=arc-20160816; b=V0OWlT8xY5wdeIiwpO2Cbh+WIXvFqwtnroYUr/JALGXruGLCh1KMK0scd1G+XaKBND goukCWdsy5wIMvZwxWYcriw+0lo0w5REqe2h/TFD5ZCY7ozQ0G5/2jpMBXSS1/mQ4tHm XlYB6j+gwIRQ+vBh/BysjOYOxgRAEnInWSCJWRG37REYg2MoDDZbvHpIc34ZdTQS4y4Y qCQBAwKX00rj3aDbNRa0rC8il/G4KCxJ2D3STH7zbZAmJMaZsFPSGLuPkCWJB+4lTsfO 6jqyqjfanCfDjVwFaQaTIHFq4RqN+I6RDN20ZbFzpqDriGZOX89/EFj0zWCbdoyMaHAs PbKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:date:message-id:from :references:to:subject; bh=n8aOmaum8O5EURR1+dIqqyVtEbw7F9E4JKC/95mTe5A=; b=Thv4pU5pPRkTarcy44tIvlct9UQEjawFGO7WTLSCvBoZliLYolCCikh9rQaMT5E4ZJ WBavwxAdYJimVp54G8S6m2SwVnUpheAyq082zio1AKLCaGC+rqh7hiCiMbJvsG1gEuoN xaL4HhuHg2bVr/CzzV9YGIx+hxLG3TPixvGEqK5/8WsfZfCTSIcw2CXnETiCJLXLnTFX Z5Rj7faCLrP+9wbpWZ0aYp6HoE1Sq7mwmTFUrhdv9ZNpw+Fcw4XMkdyOqYRdhLOeagNx Dd+3eHpfGlIGbJ5ErTTlWFpkxIPO1qlq1w7nKNLtSs7siQjsoCpYb4kMUIQx8fsPF9Kc bUqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=B0UsyfwR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si13898450pgl.23.2019.03.25.11.19.50; Mon, 25 Mar 2019 11:20:05 -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=@nvidia.com header.s=n1 header.b=B0UsyfwR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730011AbfCYSRn (ORCPT + 99 others); Mon, 25 Mar 2019 14:17:43 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:14025 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbfCYSRn (ORCPT ); Mon, 25 Mar 2019 14:17:43 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 25 Mar 2019 11:17:46 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 25 Mar 2019 11:17:43 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 25 Mar 2019 11:17:43 -0700 Received: from [10.24.70.95] (172.20.13.39) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 25 Mar 2019 18:17:39 +0000 Subject: Re: [PATCH 1/8] vfio/mdev: Fix to not do put_device on device_register failure To: Parav Pandit , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "alex.williamson@redhat.com" References: <1553296835-37522-1-git-send-email-parav@mellanox.com> <1553296835-37522-2-git-send-email-parav@mellanox.com> X-Nvconfidentiality: public From: Kirti Wankhede Message-ID: <2c096714-74cd-48ff-496f-b3919990e3e5@nvidia.com> Date: Mon, 25 Mar 2019 23:47:30 +0530 MIME-Version: 1.0 In-Reply-To: <1553296835-37522-2-git-send-email-parav@mellanox.com> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1553537866; bh=n8aOmaum8O5EURR1+dIqqyVtEbw7F9E4JKC/95mTe5A=; h=X-PGP-Universal:Subject:To:References:X-Nvconfidentiality:From: Message-ID:Date:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=B0UsyfwRhFq9SY0IogYxRthIxWcvu/aEryy4VwaMa1UlppxnOWmhFgylufA1dfCKa xDG7utLpMO4033vto5XxIZovm7gKQf1Pea7XY4ri92ZA1qzi1BwonrYdHv1ERDoMBo 3lFDdQgvKPmK89t/iruu6JL86+gkkcP1/BSnKbi6wszi+2EysxaAr03efqec5Izsuu iBb51uBWs0/Z7D4K6b6TVR3Ev0FVSUyTJ22OAQ+kJiSPVqSgbBxRlnSpqDYyTYvhAE x+qFxLP+ZNXypObDc7wjP3ZLqY8AGwptnyc0p1WgBEOMlZZdUdJfzB70h5nAiMqJtD z/lNlZBk2KkIg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/23/2019 4:50 AM, Parav Pandit wrote: > device_register() performs put_device() if device_add() fails. > This balances with device_initialize(). > > mdev core performing put_device() when device_register() fails, > is an error that puts already released device again. > Therefore, don't put the device on error. > device_add() on all errors doesn't call put_device(dev). It releases reference to its parent, put_device(parent), but not the device itself, put_device(dev). Thanks, Kirti > Fixes: 7b96953bc640 ("vfio: Mediated device Core driver") > Signed-off-by: Parav Pandit > --- > drivers/vfio/mdev/mdev_core.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c > index 0212f0e..3e5880a 100644 > --- a/drivers/vfio/mdev/mdev_core.c > +++ b/drivers/vfio/mdev/mdev_core.c > @@ -318,10 +318,8 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) > dev_set_name(&mdev->dev, "%pUl", uuid.b); > > ret = device_register(&mdev->dev); > - if (ret) { > - put_device(&mdev->dev); > + if (ret) > goto mdev_fail; > - } > > ret = mdev_device_create_ops(kobj, mdev); > if (ret) >