Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1079805ybl; Wed, 14 Aug 2019 10:21:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhFy4gkpSJfkLJTc9vje5zLjor9wlluTjtX4QLaO/J+2C9d0dG7YiRew5pOy3//K4BAiZw X-Received: by 2002:a17:902:e38b:: with SMTP id ch11mr395131plb.275.1565803318491; Wed, 14 Aug 2019 10:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803318; cv=none; d=google.com; s=arc-20160816; b=MUzwoAKscmEZHuZBG1OPI05l4fYsqktHOtYrqt7ekTsv/caOi3eaHtzZGhFXpZQO00 U093eLiVeLYuvfemQpkrmBXAyjHhx4bmpAA+P03YatVrSZOoFZhJZxEHuSU1yfdBRNsJ vlUOSV0il/x9yGG3sN8aE1c/1jI2YDIAMyhF3SFviEGRIdsAzY0+NGoHRNRH7Wt1H9vi JZa+NzIEbi0TJSoJQ0P5g5oWxNEmaNvVnS5xL7JdFcSflY5tySyLE02+52+bNoTDrKsf mMXa3z9raQTfv0ioXNZsZ/xYx9iI+OPsXGeCe+08QwTBcPRYhXJmz9hmgxmyzOicyGi7 +05g== 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=q00J9zm+lZJcJxcwdWU+otwgpP0940GuT/eNFm3/kGk=; b=B4t7UlNl1I3NCbHGHDMyBtHYrgkGTNb3PxjHS7f857A1y8o7fRD+BqjYKYjQQ700PB 0jknBucLSSBiNLOqAi62p9VQBw5+6Ye0BwnafjHglfqwk0UXONNpzqcWcD+nUqtWFlrp QSmWnr4uAA/XuKXSE5pj4gzqSdiX3VZ4lj05YQu0wXfj2LvcSdnrYlEuj5ufSQiOQQTK aB19tb6mw2BIZROT+oXiW9djQTgbM+FvBDyxqAIlbb5n2eQKRRRmHyvaHfRFpU1JI1bC jSNbgALqDWP4tUErg7UKE9Afo8K6qdM8UhMiyB5Eqk4EDxwCYMHlO7Ztcv+zTZzLFrHp 76gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LsSmwlrQ; 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 y8si177024pgk.594.2019.08.14.10.21.42; Wed, 14 Aug 2019 10:21:58 -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=LsSmwlrQ; 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 S1730322AbfHNRLJ (ORCPT + 99 others); Wed, 14 Aug 2019 13:11:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:34216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729970AbfHNRLF (ORCPT ); Wed, 14 Aug 2019 13:11:05 -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 074BD2084D; Wed, 14 Aug 2019 17:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802664; bh=XnL2R5SVJTzyTbeEXy6Ul6DQCr+YZAlH2A8KvE7+Ehc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LsSmwlrQQDF3i4RrPSzE6XZQ90CsTS8VWn32CzGajw/M6QMRkW+qDSC6cFTPDbkEC E/KF/AJUXTcOtLDj2WkZ0sSetz+rNiN+loJ4gKwnaoj/HOAhX7yT2l1wuHQPPZCx3u KvdAgYScBsDl6NsGINON8hRJlfL/kHfgdTHBBc3I= 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.19 34/91] vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn Date: Wed, 14 Aug 2019 19:00:57 +0200 Message-Id: <20190814165751.146670444@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 70a006ba4d050..4fe06ff7b2c8b 100644 --- a/drivers/s390/cio/vfio_ccw_cp.c +++ b/drivers/s390/cio/vfio_ccw_cp.c @@ -89,8 +89,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; pa->pa_iova_pfn[0] = pa->pa_iova >> PAGE_SHIFT; -- 2.20.1