From patchwork Mon Apr 21 21:53:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4027221 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7F7DBFF02 for ; Mon, 21 Apr 2014 22:03:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9AD52025A for ; Mon, 21 Apr 2014 22:03:48 +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 6C48820221 for ; Mon, 21 Apr 2014 22:03:47 +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 1WcMHT-0002Wj-5K; Mon, 21 Apr 2014 22:01:39 +0000 Received: from mail-yh0-f44.google.com ([209.85.213.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WcMHP-0002SY-9T for linux-arm-kernel@lists.infradead.org; Mon, 21 Apr 2014 22:01:35 +0000 Received: by mail-yh0-f44.google.com with SMTP id f10so4083598yha.17 for ; Mon, 21 Apr 2014 15:01:15 -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=LRtVLKrkPrg5CJEuwn4Ss2lTmaWuwky/nMO0j6YOvHE=; b=Qi2ee+8fwb1Xyfyxam6HymkUgkDIV8sEuYz3tHCnYWAvSSEn7/M029kG5M+c4+tXAe 9P+/7+b0mm6AXboumJQDsh5JsTX4rjM0SgqMJlrcZSuvJrPHQw4GzL1Lh+5MKBEP7Tsm PVQIF9lCt4NOAqEXbC/C20cHQEHh3X4TXXobsPbS0CYVy2kKgm8uZV9tetr96br7R5nU aTHG2fwFSVIExvXSie1rphVD4nOc8IXdjqS4GLZSUi9o4qDLVHjAg/i2jMUrP3IIjf+G npXI2FH3NXJrbHoxj4KcgpudoLypIEw5przm72wifwXwI2XtwXzilUWAwtIKLqW85t7s sVog== X-Gm-Message-State: ALoCoQn7tg24RZngFRG/15tnvtLlz1VX8GlHFse7U3hxqG+JVevnZiLncl7d90PkQmcNG3KdgNH/ X-Received: by 10.236.170.37 with SMTP id o25mr3359600yhl.145.1398117201582; Mon, 21 Apr 2014 14:53:21 -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 t63sm74182258yhm.32.2014.04.21.14.53.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Apr 2014 14:53:21 -0700 (PDT) From: Alex Elder To: bcm@fixthebug.org, mporter@linaro.org Subject: [PATCH v2 02/10] ARM: bcm: err, don't BUG() on SMC init failures Date: Mon, 21 Apr 2014 16:53:03 -0500 Message-Id: <1398117191-2433-3-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1398117191-2433-1-git-send-email-elder@linaro.org> References: <1398117191-2433-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140421_150135_411863_07325B82 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.5 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;