Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2514828imm; Mon, 24 Sep 2018 05:45:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ2LeGUjHhCgomKcMXyeXiI3hy2h2tdonCeVzIH8UqJOAsnnIUfysGsbUJd6GXGi0SHxjhT X-Received: by 2002:a62:76d8:: with SMTP id r207-v6mr2008212pfc.216.1537793159330; Mon, 24 Sep 2018 05:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793159; cv=none; d=google.com; s=arc-20160816; b=Cqo7QiajzzQdZ7hd6a2AFwu96HIvaDyZ0kJcdLjbkbQG/uswl3uV4CtPJhgFy84s/o PXLPm637DzgRjRDDDRkicBkLLRLS8UMQAaN3zkcWTr11la1fhq11b0a4N5BwwFiisMgi dnF8nk4H8BFwGhGHAsIQyut937hH0XTteeSrOdFxV5TrqGEMwqveCLXXpSIc1B04GZIl IHQR8WPICWUxh7Xb0UaByaImSdURoV8Tx1bjSp1CWOC/Cs1nrbIZpIf/ad0jtbZlvLsG BJe1jSOx7OrIOpp2yV4we/UTDlRXtAB+15b0ltyDVfTTAZZORtzY8Zt48GMFLn9MjKiR m5ZA== 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; bh=pxjSWJj2ORJruVnKWCFlroP9Ct0EeBecpRLKK4f965w=; b=YZud2EYBU4hvJxfAlPsdT48S/v99cCAtH5L+GmR2KCAJiPRmw+4tpo9HZ0V0DEwGFE Sg659dc3j2b7YO6dzNPRKR7vjMWT0RHK6HQ7HOyRbxCfVqHlbp8/yRKUQMTyD7bOUzkB /izxGgYV4i7KlSQ0zQBIkRBkkxU6pYjyBXv1IS0GRu6tNZ0mqsiRmNIMgWzHGv1EhngR B4VDjOqGCkpDKxJjSmGe8G8jJDQb26p8cFGaA0hET1abegSmeYz1wf3aeNrjXHqOs0IX Dt4UQoI4TnwWbjBwHb1a7FZcNtaGmh+yKDzWUKnKtGF71iNPs6rxsDTI3J5SYT13aEby h0XA== 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 n15-v6si5039873pgc.143.2018.09.24.05.45.42; Mon, 24 Sep 2018 05:45:59 -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 S2389015AbeIXSpX (ORCPT + 99 others); Mon, 24 Sep 2018 14:45:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59446 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732541AbeIXSpW (ORCPT ); Mon, 24 Sep 2018 14:45:22 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 12472109A; Mon, 24 Sep 2018 12:43:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wei Yongjun , Robert Jarzmik , Linus Walleij , Sasha Levin Subject: [PATCH 4.18 200/235] gpio: pxa: Fix potential NULL dereference Date: Mon, 24 Sep 2018 13:53:06 +0200 Message-Id: <20180924113124.156996781@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wei Yongjun [ Upstream commit 9506755633d0b32ef76f67c345000178e9b0dfc4 ] platform_get_resource() may fail and return NULL, so we should better check it's return value to avoid a NULL pointer dereference a bit later in the code. This is detected by Coccinelle semantic patch. @@ expression pdev, res, n, t, e, e1, e2; @@ res = platform_get_resource(pdev, t, n); + if (!res) + return -EINVAL; ... when != res == NULL e = devm_ioremap(e1, res->start, e2); Signed-off-by: Wei Yongjun Acked-by: Robert Jarzmik Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-pxa.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -665,6 +665,8 @@ static int pxa_gpio_probe(struct platfor pchip->irq0 = irq0; pchip->irq1 = irq1; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; gpio_reg_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!gpio_reg_base)