From patchwork Fri Sep 14 07:37:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenyu Wang X-Patchwork-Id: 10600335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80F2414DA for ; Fri, 14 Sep 2018 07:37:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FC1D2B2F3 for ; Fri, 14 Sep 2018 07:37:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1166E2B506; Fri, 14 Sep 2018 07:37:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 985832B2F3 for ; Fri, 14 Sep 2018 07:37:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727577AbeINMuM (ORCPT ); Fri, 14 Sep 2018 08:50:12 -0400 Received: from mga03.intel.com ([134.134.136.65]:1408 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726822AbeINMuM (ORCPT ); Fri, 14 Sep 2018 08:50:12 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Sep 2018 00:36:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,372,1531810800"; d="scan'208";a="90398858" Received: from debian-skl.sh.intel.com ([10.239.13.15]) by orsmga001.jf.intel.com with ESMTP; 14 Sep 2018 00:36:58 -0700 From: Zhenyu Wang To: kvm@vger.kernel.org Cc: Alex Williamson , Kirti Wankhede Subject: [PATCH] vfio/mdev: fix missed mdev free in mdev_device_create() error path Date: Fri, 14 Sep 2018 15:37:16 +0800 Message-Id: <20180914073716.26092-1-zhenyuw@linux.intel.com> X-Mailer: git-send-email 2.19.0.rc1 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add mdev kfree in mdev_device_create() error path which seems to be ignored. Fixes: 7b96953bc640 ("vfio: Mediated device Core driver") Cc: Alex Williamson Cc: Kirti Wankhede Signed-off-by: Zhenyu Wang --- drivers/vfio/mdev/mdev_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index 0212f0ee8aea..40a8f7280639 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -294,7 +294,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) if (!uuid_le_cmp(tmp->uuid, uuid)) { mutex_unlock(&mdev_list_lock); ret = -EEXIST; - goto mdev_fail; + goto parent_put; } } @@ -302,7 +302,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) if (!mdev) { mutex_unlock(&mdev_list_lock); ret = -ENOMEM; - goto mdev_fail; + goto parent_put; } memcpy(&mdev->uuid, &uuid, sizeof(uuid_le)); @@ -342,6 +342,8 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) create_fail: device_unregister(&mdev->dev); mdev_fail: + kfree(mdev); +parent_put: mdev_put_parent(parent); return ret; }