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 9DB75C4646B for ; Thu, 20 Jun 2019 18:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 72F0320675 for ; Thu, 20 Jun 2019 18:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561055505; bh=vqrdQTg9ktMGcTqSaqBpgB/ML4PTuVErqQkNxhuP0fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SGHRohfSJpU6qaFeTJMeauS/KdSitaquO+ogeVfgBnR19JyFj/FJppPsMArz/KVHr CZNOELKFnA67WLKGPl0AoknKZmxepaBiXUIEyApHENw9dmxp/4+ZjPMUTCb9zVItSY masTzZrfj1E7lEyVDnr6Dj60azC8ylEyUIMmjEuM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbfFTR7Q (ORCPT ); Thu, 20 Jun 2019 13:59:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:46490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbfFTR7N (ORCPT ); Thu, 20 Jun 2019 13:59:13 -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 5E1F22084A; Thu, 20 Jun 2019 17:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561053552; bh=vqrdQTg9ktMGcTqSaqBpgB/ML4PTuVErqQkNxhuP0fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7t0GETMj0+UNMdPwaAbhYIirpQ0YAMwKZ/VF89/YyjidviPPxFzwTpoaiZf8Tccf R9krrTSkR0c2dpUfqWwiE/4uHZCHY/zhTYTT4ad3A2W0NwDByVIb7FOlzY42wSQbMo w3K2zTenwRqZHBcDQ3ZbuRg54ISjAuOt7CKLrxr0= 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.4 28/84] PCI: rcar: Fix a potential NULL pointer dereference Date: Thu, 20 Jun 2019 19:56:25 +0200 Message-Id: <20190620174341.991787283@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174337.538228162@linuxfoundation.org> References: <20190620174337.538228162@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 414c33686621..b18cf12731ee 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -737,6 +737,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