Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3698429ybv; Mon, 10 Feb 2020 04:56:15 -0800 (PST) X-Google-Smtp-Source: APXvYqxfWm3qxRJYbPgWNqnsVzVwW3dzwwub/6CE8Uydor7hUinoUYUgARucEmnjUyikNOj5u5IR X-Received: by 2002:aca:2312:: with SMTP id e18mr760346oie.34.1581339375350; Mon, 10 Feb 2020 04:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339375; cv=none; d=google.com; s=arc-20160816; b=D+Mf+0+45v6cd3OYk8GFiaiRR/qjxd0t69uyc/AHQDSX2gE0gPn8kPpXCIxh4DMpl8 Nc5D2uD1CGVIJtElaKDMldt4rJYIpoRnz1Ne+XlLkZWH9/TkEC9+ULJtqyYHQvUZHTpF I77McxjAP+n0DDxNKT4oOsR1/14uUl2SeTs9vjUjDBKO2xMtLtqbPbw7C3e9eJdXYkgU t5ZnQHEH1GsUIEgkBB2wwghCrG/x2Vn8FD0W+R6XO13jBAGCtVBn85XpES7vErbvC1RK 0TXOFJ5CmACfdpn6/hcR36/jHT8zGhgHCIi3x9Fcb+XLIW5ucLnOZDi7JVz4oCebKoKB p/6g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MZr8kODXjrT1otrCffB4+Ub9Hyfs+epNONn2cE8BLCo=; b=wFGpw/0IFa0pk4cQfUz9Xky0BxH09UZYDy/zeTiVXZTPOrIAbgfei01DG4qzn2Ksyq t+p+TKOkFa7+jTD3g7L6JYQqBH4d3iysWbpvR0GN97qwZeNjVRwMvcBg+8KYk3s/PUYH UobSUr6qm2zfgbQFZnDGPVuQtwUcgeJSTFE61Ee2M9b0wrJ4WLvoWw2jY+qCAqkoeNbp pmk/umB63B4vm35Sgt46ctmFokbdr76xhoEEUoX/cIACyUTZjcAmUJMDSdp+LiRLpOVl EQUtNI4fVCNPnWE8Slc55mMgMNQzKWbBrE9Nrqxy94G7gMLxGRFRBcP1c7qD/FnG5ag/ ChCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zlnAlzJE; 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 d1si133742oth.158.2020.02.10.04.56.03; Mon, 10 Feb 2020 04:56:15 -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; dkim=pass header.i=@kernel.org header.s=default header.b=zlnAlzJE; 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 S1728791AbgBJMzz (ORCPT + 99 others); Mon, 10 Feb 2020 07:55:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:44324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729793AbgBJMlo (ORCPT ); Mon, 10 Feb 2020 07:41:44 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A570220873; Mon, 10 Feb 2020 12:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338503; bh=RRVK0oQs8vlOlni2dD9fgIUqyQiHBCOg6uoiikTwBws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zlnAlzJE+cEdJDG/DpaJ7dZ6Qx69NItgTw6qEqeshKCnRCMWmj6ZXLtbDLSS+ildo ibqdJvpulcmY+G1xuuLF+w1bkRY/3Gm0IYyYgV/4KyGTPeFQm/AhCGdfMGv+Kdq9Qz 7BIPGOXVT+cSsHm0hbvLES3gprYXMqD6jNjrCIEw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Wei Wang , Liang Li , David Hildenbrand Subject: [PATCH 5.5 302/367] virtio_balloon: Fix memory leaks on errors in virtballoon_probe() Date: Mon, 10 Feb 2020 04:33:35 -0800 Message-Id: <20200210122451.409743460@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Hildenbrand commit 1ad6f58ea9364b0a5d8ae06249653ac9304a8578 upstream. We forget to put the inode and unmount the kernfs used for compaction. Fixes: 71994620bb25 ("virtio_balloon: replace oom notifier with shrinker") Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Wei Wang Cc: Liang Li Signed-off-by: David Hildenbrand Link: https://lore.kernel.org/r/20200205163402.42627-3-david@redhat.com Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/virtio/virtio_balloon.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -901,8 +901,7 @@ static int virtballoon_probe(struct virt vb->vb_dev_info.inode = alloc_anon_inode(balloon_mnt->mnt_sb); if (IS_ERR(vb->vb_dev_info.inode)) { err = PTR_ERR(vb->vb_dev_info.inode); - kern_unmount(balloon_mnt); - goto out_del_vqs; + goto out_kern_unmount; } vb->vb_dev_info.inode->i_mapping->a_ops = &balloon_aops; #endif @@ -913,13 +912,13 @@ static int virtballoon_probe(struct virt */ if (virtqueue_get_vring_size(vb->free_page_vq) < 2) { err = -ENOSPC; - goto out_del_vqs; + goto out_iput; } vb->balloon_wq = alloc_workqueue("balloon-wq", WQ_FREEZABLE | WQ_CPU_INTENSIVE, 0); if (!vb->balloon_wq) { err = -ENOMEM; - goto out_del_vqs; + goto out_iput; } INIT_WORK(&vb->report_free_page_work, report_free_page_func); vb->cmd_id_received_cache = VIRTIO_BALLOON_CMD_ID_STOP; @@ -953,6 +952,12 @@ static int virtballoon_probe(struct virt out_del_balloon_wq: if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) destroy_workqueue(vb->balloon_wq); +out_iput: +#ifdef CONFIG_BALLOON_COMPACTION + iput(vb->vb_dev_info.inode); +out_kern_unmount: + kern_unmount(balloon_mnt); +#endif out_del_vqs: vdev->config->del_vqs(vdev); out_free_vb: