Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1072703ybl; Wed, 14 Aug 2019 10:15:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfN/1vHTjlBPXY7MdtfM1v0+MKKQQ5sD3X+zq/Ylh27kzI84QTm7nDP1FszJAmFXDcUV0l X-Received: by 2002:a65:41c6:: with SMTP id b6mr187865pgq.269.1565802914788; Wed, 14 Aug 2019 10:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802914; cv=none; d=google.com; s=arc-20160816; b=bNpBhQ4mdKhfRAQ6N+vJV7L/BFwaBgDdeQiY4znbOZ9stB7G3El2Cwndxvo1MxdG5l FTM91q+Rs+dLa4tUuvSLBrMjNscmwwe8MiWk1QWW7NhelLSpM2nxv/NJT47L+Hv90Ngi ZkcC7oLJZSny8X0HUcgPiu21FjyWI4NyS+c+sjCXDT7tmGF24ScRDUGlKfoekZ418zDN 2nsqd3IAwieyupKmGN/9yj4RRAt+ZxTmBAaX5vm98G4yVWpQoQJishksLmturt5ssrN6 +GtzmEDIq7UYVGuYTQFsWjSEQVs8MoGNdZC9d742OV55vM7bIBqfwS8YCExofc/IcaUu 738w== 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=DXjhWZLVJKwVNUlZhV7+hbzWATkGfvDE9QjrlsD2VEg=; b=f/d8ELpE5aWqxnYq0uM3rTbTKhK/juaMeM3HKL0nfEYR4aEQ795DQ0BW/VN05W81fY OKVD74GhP9fMpQVa67sPL98zc911jXcSspBGcrlNUMin/iKW3FFiCPsMAT3spRZFRmVc S4d9xVn0vklogPxo1Uso46fRjakFUIaDv5t8/2MPMoxVM56KY8G09OQDoh9tpujvDasq xgso5sG+cnBLCfeGyqPxi9FHv7YryFb1yi7l+OsN309RA/aWSWoBqhymw1bWfH+azib6 20BjUb1sc/uzLpXV+J4dm3q8g/MnDEGXI3QSLwB29iGOj+985jWY5nwWn+4YIm7vnbX0 y+Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ha8o+U8w; 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 d18si210081pjz.58.2019.08.14.10.14.58; Wed, 14 Aug 2019 10:15:14 -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=@kernel.org header.s=default header.b=Ha8o+U8w; 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 S1730847AbfHNRNK (ORCPT + 99 others); Wed, 14 Aug 2019 13:13:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730828AbfHNRNH (ORCPT ); Wed, 14 Aug 2019 13:13:07 -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 BD9EB2063F; Wed, 14 Aug 2019 17:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802787; bh=P6AgbGaHMiyIDWjZWeRZJ9XZLAL9cDrP6KEQPdIE1RQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ha8o+U8wDvXcxfLGq7LjHXRKaAve268Nu6nAphNssYBXHNLI09Fx6eidgrzOXWgVa qlp/vYjhZZAVP72JylQy86lqHeqIqWUdedrlbi3bh3d7AK/JTN7lp2gGGQ0AQx0HUm 8dieO/Du5T00NBsChneyAv4fI3BSyjIG72DpA88Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Farhan Ali , Eric Farman , Cornelia Huck , Sasha Levin Subject: [PATCH 4.14 26/69] vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn Date: Wed, 14 Aug 2019 19:01:24 +0200 Message-Id: <20190814165747.257519174@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@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 [ Upstream commit c1ab69268d124ebdbb3864580808188ccd3ea355 ] So we don't call try to call vfio_unpin_pages() incorrectly. Fixes: 0a19e61e6d4c ("vfio: ccw: introduce channel program interfaces") Signed-off-by: Farhan Ali Reviewed-by: Eric Farman Reviewed-by: Cornelia Huck Message-Id: <33a89467ad6369196ae6edf820cbcb1e2d8d050c.1562854091.git.alifm@linux.ibm.com> Signed-off-by: Cornelia Huck Signed-off-by: Sasha Levin --- drivers/s390/cio/vfio_ccw_cp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c index 1419eaea03d84..5a9e457caef33 100644 --- a/drivers/s390/cio/vfio_ccw_cp.c +++ b/drivers/s390/cio/vfio_ccw_cp.c @@ -119,8 +119,10 @@ static int pfn_array_alloc_pin(struct pfn_array *pa, struct device *mdev, sizeof(*pa->pa_iova_pfn) + sizeof(*pa->pa_pfn), GFP_KERNEL); - if (unlikely(!pa->pa_iova_pfn)) + if (unlikely(!pa->pa_iova_pfn)) { + pa->pa_nr = 0; return -ENOMEM; + } pa->pa_pfn = pa->pa_iova_pfn + pa->pa_nr; ret = pfn_array_pin(pa, mdev); -- 2.20.1