Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2653248pxa; Mon, 17 Aug 2020 15:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ7Q660jCxEtZ4LPOJU+MnhJNmzqOFLwlARuED5xLRlpAXLjOKAINi91KL3+zyeukcafMw X-Received: by 2002:a05:6402:2285:: with SMTP id cw5mr16787511edb.242.1597703743189; Mon, 17 Aug 2020 15:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597703743; cv=none; d=google.com; s=arc-20160816; b=hilNZiX2onkuGOOMHU7bgVqaLTAuOQvZ4kdBe2FPqufCCPGt6L50MbetXkNsyQyw4d aopes2Wh4QXNpIsGwud9dKqlASPkDdO7i6YijoXjQILTjaXDFhR5kcUQnVBX8e6JQdWp Zjsexz1N/QucIst0EvYk9F1idJMWKzfUGDhz0pNWrdo/fLB5RTcQNJKSM4jl23hjzhsw IQAM9z+SZwT9QipUt3ubsYmuZCDCKiV5m+R/gwr2ri0TmdrOfDKPYo0A9EHFouERyrin Y2COWVK5tSFNKQIiNvUnBMq2EsLSCMaIdJklEGs73W17NEEooF1x7DctnCtC5BEP1+7g W/cw== 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=qT7i3WFenYnuQ6Ssvs2jULbpzh2PpUAngPJdR4oNDN0=; b=nOsXlwimnj03/77Z4RMWFjwfh56FFJ6QnYyv6s2n32rEhiFo3gyO1pesdrp1jZ9VkV xuJ6LSFHd7x/jB/r8h0C/mep3SRs4GlimGKQwL3rKp4p26djQWEtAQjORcqfrbEjAMKG Bg8UymHnL+SoGCMoFq/AuaD2dH+k7XLS3mdtqa05nnT7ilJovs0fD5Lk8CPO8yErCPz1 35IZBSngxhTHvxpYCdE85qhnFtOqhfSQIgIdlBwj60cf6AYQJht1AZVoCA0OEeHO/4IF Ikx/9+Ol5mRm/S/oJxoZZatIMn+d33WYJnEv+Dvawc6/gSZ3tJ5sd/hC5usSqwp1WtyH RyFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lWsAAnSJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x2si12529601edj.273.2020.08.17.15.35.20; Mon, 17 Aug 2020 15:35:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lWsAAnSJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731141AbgHQRWD (ORCPT + 99 others); Mon, 17 Aug 2020 13:22:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:56732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731139AbgHQQSB (ORCPT ); Mon, 17 Aug 2020 12:18:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 B3322207FB; Mon, 17 Aug 2020 16:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597681080; bh=AeWOSZs2Ggfl1t1WNA/c3wR5SFzllGTVFS/NVXtR+ow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lWsAAnSJMclLadHb4sLLTJtuE2fVlOF0tBeu34x580tm2fM/bPCDibb1558F8sGJP BLIqMMtTvMcI9iyWD06XLP4cAW9IAjShJiJSB8tYD3RTJ/80OpHFt5YEYgwZ3P10oh y1hpYn4CEREyy7kFX/w4JVBPBRWmHh28Ck1NaUSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Juergen Gross Subject: [PATCH 4.19 166/168] xen/balloon: fix accounting in alloc_xenballooned_pages error path Date: Mon, 17 Aug 2020 17:18:17 +0200 Message-Id: <20200817143741.956665749@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143733.692105228@linuxfoundation.org> References: <20200817143733.692105228@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: Roger Pau Monne commit 1951fa33ec259abdf3497bfee7b63e7ddbb1a394 upstream. target_unpopulated is incremented with nr_pages at the start of the function, but the call to free_xenballooned_pages will only subtract pgno number of pages, and thus the rest need to be subtracted before returning or else accounting will be skewed. Signed-off-by: Roger Pau Monné Reviewed-by: Juergen Gross Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200727091342.52325-2-roger.pau@citrix.com Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/balloon.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -632,6 +632,12 @@ int alloc_xenballooned_pages(int nr_page out_undo: mutex_unlock(&balloon_mutex); free_xenballooned_pages(pgno, pages); + /* + * NB: free_xenballooned_pages will only subtract pgno pages, but since + * target_unpopulated is incremented with nr_pages at the start we need + * to remove the remaining ones also, or accounting will be screwed. + */ + balloon_stats.target_unpopulated -= nr_pages - pgno; return ret; } EXPORT_SYMBOL(alloc_xenballooned_pages);