Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1061205ybl; Wed, 14 Aug 2019 10:05:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZK9ld45yrhunczPjDJqROml5+RHvjd/VH/U3yG1TjWc2ghwJeAAKKq+3KQZEvd4RKmX98 X-Received: by 2002:aa7:8392:: with SMTP id u18mr998313pfm.72.1565802339888; Wed, 14 Aug 2019 10:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802339; cv=none; d=google.com; s=arc-20160816; b=CiHbN7r9txCrqOhM2dIonw5UE1Gv8qtgNIbvvjbHkiKej7eyM5IodeSU9z5TKlIf1p 6Fxq6ffdZUb0J2EWhe9jbo8Cq1m/zrQxJto6+li7kYY/7zZxmdHE6lSF9gn4ue++7aaB 5kuV/ukS+sQC9ZJqJreRNiMXzQQiOci9mtcNcLg44BfMLXhB/GAZNhb/hbVgI0TQFzsC pddd8QfU73ZRJQbH0lw8pfpxxKS7keyUZoXtTEJzuf4WQgcltqXDmu4cCK6RfDGlIVqV 8LQBML/4Bgh0815GzQbuKdGx+Tqcd3IQnst1dEwjzrymI2y1mAD/YCtwHkW4cBCd0XpC dkIA== 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=tIEytUeZQlfTdIusOUDlBOdPvgODL1K4Lb8ltdWvjCA=; b=tBlE6ihHUJ3ZphOZgdN7O8TSE4iHdn6ucOlBypO71pKd0GNrkw5kIpU7kbHDwX3a0d J7guxLoaqaQCp0p6I2/9mAo03GsdAhBIlloJ+WYVKnhrLz2Ixuz7eSDGoiE8Eo8sYWCn yl7F8wtdrBTwGOuGuyHtAjIcWBF+a15fSXb8bTrxr0mZVtVGjUqCV0Fc/C8Gq6KzYd2d H+lGrAe0le6bu9Spz0RnBKgFWUGOVgEwT8UfxPI7PAjHaaxTUjQmJ+Zs6viEVew8NC+C /VZrD38idzGR/F6sK1DV0/RMLyR4Y9HyFgmQOAeH8KyVjH/f3JB6NKfJZplcRIUq/apD rdDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=laj6tMLr; 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 u3si243443plq.143.2019.08.14.10.05.23; Wed, 14 Aug 2019 10:05:39 -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=laj6tMLr; 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 S1729137AbfHNREK (ORCPT + 99 others); Wed, 14 Aug 2019 13:04:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:52952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729127AbfHNREJ (ORCPT ); Wed, 14 Aug 2019 13:04:09 -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 CAB2F208C2; Wed, 14 Aug 2019 17:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802248; bh=dcNlIq3Uf0l0lx13G3Fyg5C2xZf/pldIfA1pAiWLhjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=laj6tMLrxxoX6/VMhNT+f3OowbXoXsGg0fBgMwkqrnceIhkeM2PEDa2BrCgJaR06w FqWfEZ3rrU4RkcSaXe6SkOwHG0N+UaUf9ZeprtzBvzNEb54s06It3maQUDlz9vxG8H NRuUpcpFDMT/jm6JdCZWS1AF1zeYMxRewjNEZYvo= 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 5.2 051/144] vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn Date: Wed, 14 Aug 2019 19:00:07 +0200 Message-Id: <20190814165801.962212682@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 0e79799e9a719..79eb40bdaf9f4 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