From patchwork Fri Apr 18 02:30:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4012871 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ECCAD9F336 for ; Fri, 18 Apr 2014 02:33:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39CAE2035D for ; Fri, 18 Apr 2014 02:33:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6CCD420328 for ; Fri, 18 Apr 2014 02:33:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WayZr-0004af-9y; Fri, 18 Apr 2014 02:30:55 +0000 Received: from mail-ig0-f169.google.com ([209.85.213.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WayZd-0004S2-Dr for linux-arm-kernel@lists.infradead.org; Fri, 18 Apr 2014 02:30:42 +0000 Received: by mail-ig0-f169.google.com with SMTP id h18so586119igc.4 for ; Thu, 17 Apr 2014 19:30:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hgIdsHZ9oemJuMsVxTnd3Asjiy9OGWRxK6OaTI241Tw=; b=HAIs41nWyMQ8CjFacD3iLuymfEDRNxMt253LtZ1szqceWNebsqKDVXoXLwSPY9DduJ +Q+B9GhLUyRfKiz6yrsnLWCPwMLIpcRDLnTiGFVjCN5WJqkq+PYd+u3iOXtjZLN4V/Mk UmHH9icOPJlFAJ0UFYpcVfYpvj5lC9fidBQYGXF5bEe6biPrZ9U/+Nv072Ms3uj35X2L 8sTAXDILwc44vZh9gqoKSpRWvBNXd/dWR/cC4rcGRWhiMfmUy8SS6bC1AgZqPMXXOnjS z2DU5bth/IXWaqEOHn8QNQz8OecD+Mk1aIuFh3M/kzOG5SM4/m/Yptyzii8RjqN2oqBP 2ooQ== X-Gm-Message-State: ALoCoQlKPhpGtVs0VoRzK65pX2v0VGnxHJT7SvSUsfk98x6LF0BNdmjLXNskZM7J2+oO5kt4zZTb X-Received: by 10.50.50.146 with SMTP id c18mr846936igo.42.1397788219955; Thu, 17 Apr 2014 19:30:19 -0700 (PDT) Received: from localhost.localdomain (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id m8sm673967igx.9.2014.04.17.19.30.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Apr 2014 19:30:19 -0700 (PDT) From: Alex Elder To: bcm@fixthebug.org, mporter@linaro.org Subject: [PATCH 02/10] ARM: bcm: err, don't BUG() on SMC init failures Date: Thu, 17 Apr 2014 21:30:07 -0500 Message-Id: <1397788215-20279-3-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397788215-20279-1-git-send-email-elder@linaro.org> References: <1397788215-20279-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140417_193041_628800_684CDC19 X-CRM114-Status: GOOD ( 12.65 ) X-Spam-Score: -0.7 (/) Cc: bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Several conditions in bcm_kona_smc_init() are handled with BUG_ON(). That function is capable of returning an error, so do that instead. Also, don't assume of_get_address() returns a valid pointer. Signed-off-by: Alex Elder Reviewed-by: Tim Kryger Reviewed-by: Markus Mayer Reviewed-by: Matt Porter --- arch/arm/mach-bcm/bcm_kona_smc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c b/arch/arm/mach-bcm/bcm_kona_smc.c index d881c72..ddc2f17 100644 --- a/arch/arm/mach-bcm/bcm_kona_smc.c +++ b/arch/arm/mach-bcm/bcm_kona_smc.c @@ -45,6 +45,7 @@ static const struct of_device_id bcm_kona_smc_ids[] __initconst = { int __init bcm_kona_smc_init(void) { struct device_node *node; + const __be32 *prop_val; /* Read buffer addr and size from the device tree node */ node = of_find_matching_node(NULL, bcm_kona_smc_ids); @@ -52,12 +53,17 @@ int __init bcm_kona_smc_init(void) return -ENODEV; /* Don't care about size or flags of the DT node */ - bridge_data.buffer_addr = - be32_to_cpu(*of_get_address(node, 0, NULL, NULL)); - BUG_ON(!bridge_data.buffer_addr); + prop_val = of_get_address(node, 0, NULL, NULL); + if (!prop_val) + return -EINVAL; + + bridge_data.buffer_addr = be32_to_cpu(*prop_val); + if (!bridge_data.buffer_addr) + return -EINVAL; bridge_data.bounce = of_iomap(node, 0); - BUG_ON(!bridge_data.bounce); + if (!bridge_data.bounce) + return -ENOMEM; bridge_data.initialized = 1;