Received: by 10.213.65.68 with SMTP id h4csp1758010imn; Mon, 19 Mar 2018 12:26:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELuqt8W9b6T1nR8QFLgB6qIP97NCYWZylSqJherRUZDEnZGzWoKdjV8bfVJfm/HZhar+uyR/ X-Received: by 2002:a17:902:a610:: with SMTP id u16-v6mr13435340plq.293.1521487602886; Mon, 19 Mar 2018 12:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521487602; cv=none; d=google.com; s=arc-20160816; b=QrfOysqPsTchTFNXagNjVtQHoX5bUrRsCX5g9F8rROO8d8Ma2cAk+9BY9ZnnTQdd4k nuPjV1AOzKVzv43KvIW2ZHJqIryg+BcrCx7EKWrqwBLZJ32yogqBX2a373HRxDCAx6EG 6hJHASGPLEGCl9y9HkHraQx5NGj4Y1obqKWVuXUYSisLV4RWN5/L9jaT6y24U7bbHS4d Xtda34SWTFgAadlqG7bg2tUQrrc/4k+1Z/an1qlVt3FflSXvEN4WGENoACvH3m4iVtFk G3zZ2sqENLao4NjlIrsKcyuen609YIyrFiqcqPKwKgFLSbRI2+hCVC8a3MV+/2w1nlw/ j42A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vw7HZgYdJjpQBsz2kbijFgH0lbw8Ud7c+eYxnaBXclQ=; b=agi54eziUN5c5W9XBueaFJZeSdhXjbS7OjrTMOlhcMJn0+HSTi+aSc3JdF9Hu5dLND L8iXiqfsE7BZXIPFuzTfVIWNzvDK91Ngjx+A3hO3Yu20gOmgUy8mKwj8WU4j2LfSAO07 AUE/pWOhIf6cEPMC7OqjuoMixQ6wxws/1wGUabKzU+CzRCMx1QOVIBnjoALyaAcQlmI6 CHJ1lMQvdhgc03fd5qlOSsm5i86012TXh7+p0F0mBSB3+M7LEv8D7pE7U6B13Qfy0Gxa NJxr4Ljmzum7qlDAqoRwv+k9hqsC7khvuaNBNetRu4SJ/xnKp0ox5Oq6AiE4LnWjjIJj rjEA== ARC-Authentication-Results: i=1; mx.google.com; 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 j129si421357pfb.311.2018.03.19.12.26.28; Mon, 19 Mar 2018 12:26:42 -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; 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 S1031268AbeCSSYi (ORCPT + 99 others); Mon, 19 Mar 2018 14:24:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49960 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969670AbeCSSYb (ORCPT ); Mon, 19 Mar 2018 14:24:31 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7F51CD09; Mon, 19 Mar 2018 18:24:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Kardashevskiy , David Gibson , Alex Williamson , Sasha Levin Subject: [PATCH 4.9 148/241] vfio/spapr_tce: Check kzalloc() return when preregistering memory Date: Mon, 19 Mar 2018 19:06:53 +0100 Message-Id: <20180319180757.313717482@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexey Kardashevskiy [ Upstream commit 3393af24b665cb0aea7353b05e522b03ab1e7d73 ] This adds missing checking for kzalloc() return value. Fixes: 4b6fad7097f8 ("powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown") Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/vfio/vfio_iommu_spapr_tce.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -195,6 +195,11 @@ static long tce_iommu_register_pages(str return ret; tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL); + if (!tcemem) { + mm_iommu_put(container->mm, mem); + return -ENOMEM; + } + tcemem->mem = mem; list_add(&tcemem->next, &container->prereg_list);