From patchwork Wed Mar 13 03:24:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 2260971 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7EA563FD8C for ; Wed, 13 Mar 2013 03:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932907Ab3CMDbW (ORCPT ); Tue, 12 Mar 2013 23:31:22 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:39996 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932893Ab3CMD3g (ORCPT ); Tue, 12 Mar 2013 23:29:36 -0400 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r2D3THHQ030911; Tue, 12 Mar 2013 22:29:17 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2D3THJm007077; Tue, 12 Mar 2013 22:29:17 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Tue, 12 Mar 2013 22:29:17 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.74.241]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2D3THAd011182; Tue, 12 Mar 2013 22:29:17 -0500 From: Suman Anna To: Greg Kroah-Hartman CC: Linus Walleij , Russell King , Arnd Bergmann , Tony Lindgren , Ohad Ben-Cohen , , , , Omar Ramirez Luna , Loic Pallardy , Suman Anna , Fernando Guzman Lugo Subject: [PATCHv3 12/14] mailbox/omap: check iomem resource before dereferencing it Date: Tue, 12 Mar 2013 22:24:28 -0500 Message-ID: <1363145068-14752-1-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 1.8.1.2 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Add a NULL check for iomem resource in mailbox probe functions. Signed-off-by: Fernando Guzman Lugo Signed-off-by: Suman Anna --- drivers/mailbox/mailbox-omap1.c | 3 +++ drivers/mailbox/mailbox-omap2.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/drivers/mailbox/mailbox-omap1.c b/drivers/mailbox/mailbox-omap1.c index 7b30157..4441872 100644 --- a/drivers/mailbox/mailbox-omap1.c +++ b/drivers/mailbox/mailbox-omap1.c @@ -179,6 +179,9 @@ static int omap1_mbox_probe(struct platform_device *pdev) list[0]->irq = platform_get_irq_byname(pdev, "dsp"); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mem) + return -ENOMEM; + mbox_base = ioremap(mem->start, resource_size(mem)); if (!mbox_base) return -ENOMEM; diff --git a/drivers/mailbox/mailbox-omap2.c b/drivers/mailbox/mailbox-omap2.c index 72f8368..eed5a3d 100644 --- a/drivers/mailbox/mailbox-omap2.c +++ b/drivers/mailbox/mailbox-omap2.c @@ -296,6 +296,11 @@ static int omap2_mbox_probe(struct platform_device *pdev) } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mem) { + ret = -ENOMEM; + goto free_privblk; + } + mbox_base = ioremap(mem->start, resource_size(mem)); if (!mbox_base) { ret = -ENOMEM;