From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C75CC43613 for ; Thu, 20 Jun 2019 18:27:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0552020675 for ; Thu, 20 Jun 2019 18:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561055261; bh=xOkeqYXcp++ZxaywKh3WpYy0AR+YRLzc6kZbgvvkcoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1y8wLDVIleZQXt3ibueRE46cubSkdxydP/gvecuYbV3Su6epYJCJdDVtjThe56oiD 0/89uTPk0UVo2P43PQyhZDXRx4nGUF7tjExqjeESCraIx61ZJETW6PkyGVPiSTBdmG YmEbUCVk6vnsga9LlX9iQjjfE9QiR+SpADTxr+uI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726440AbfFTSEr (ORCPT ); Thu, 20 Jun 2019 14:04:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:57442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727923AbfFTSEq (ORCPT ); Thu, 20 Jun 2019 14:04:46 -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 2B62F21537; Thu, 20 Jun 2019 18:04:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561053885; bh=xOkeqYXcp++ZxaywKh3WpYy0AR+YRLzc6kZbgvvkcoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o3X797YhbMyhgy1Skw4HNeyANwMBHwzxjZdap3AYhaq7fSBzac+f5R2mHpl9cuGHg +cAZ9cnsC1r2HaYb0ICdpxtXi8Kq9gIlO7bx72xwIr41NRF5ae+/jNCieCY+KDYjOY yI8MlflSR2TmuG6cWejOwM4AvDPXiqAC2wEqqb5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Lorenzo Pieralisi , Ulrich Hecht , Geert Uytterhoeven , Simon Horman , Sasha Levin Subject: [PATCH 4.9 044/117] PCI: rcar: Fix a potential NULL pointer dereference Date: Thu, 20 Jun 2019 19:56:18 +0200 Message-Id: <20190620174354.617213209@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174351.964339809@linuxfoundation.org> References: <20190620174351.964339809@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit f0d14edd2ba43b995bef4dd5da5ffe0ae19321a1 ] In case __get_free_pages() fails and returns NULL, fix the return value to -ENOMEM and release resources to avoid dereferencing a NULL pointer. Signed-off-by: Kangjie Lu Signed-off-by: Lorenzo Pieralisi Reviewed-by: Ulrich Hecht Reviewed-by: Geert Uytterhoeven Reviewed-by: Simon Horman Signed-off-by: Sasha Levin --- drivers/pci/host/pcie-rcar.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index d6196f7b1d58..77d931178178 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -886,6 +886,10 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) /* setup MSI data target */ msi->pages = __get_free_pages(GFP_KERNEL, 0); + if (!msi->pages) { + err = -ENOMEM; + goto err; + } base = virt_to_phys((void *)msi->pages); rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR); -- 2.20.1