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: 28744 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 59E162032B for ; Mon, 21 Apr 2014 21:54:51 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wp4sf30254137obc.0 for ; Mon, 21 Apr 2014 14:54:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=aRkzWz8R2uZizBnn9gj1MJZTTj/yJEJlJWScas5YVOg=; b=PnzzvOYbkz1II+uCiLV3n08hjACFIebssxHDqLbfTAYu/RSCzQz4dJCY3j40UDrt0E z/iSr0nekUFUauv9h/La7b7CO7GjT3TT0Xw1yp0YEC/zq6vuEIcKsAAirQ5PyRBpyjtl EMw+5YSMo9NoBj7t3lqIwkkHzs/7MqjBlt9TfY+wjVUG0Mk41UvCqOqi8dwyNB0MxVp/ Kztl9tyTZlyMh4fH4RR+SoSkptJunn7/foTNXI6YL/8wpM4PkrLaACjb6+L68m3wUhcD /Ln79XwPyJ12X/TYvu5AgPn+kHjQpzZkbgqsT0Z0qkb5bWLNf0ESBa2x1p5uz0siAspa W5mw== X-Gm-Message-State: ALoCoQnhHGilq31P2XkN/OatXOXXT/nC3XrJM2nsHnmfibwQ2GZc4eXZ7GWWF98vgXMThEvbw3LY X-Received: by 10.182.16.199 with SMTP id i7mr20381444obd.42.1398117290726; Mon, 21 Apr 2014 14:54:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.22 with SMTP id 22ls2517353qgi.63.gmail; Mon, 21 Apr 2014 14:54:50 -0700 (PDT) X-Received: by 10.52.116.101 with SMTP id jv5mr13372341vdb.11.1398117290491; Mon, 21 Apr 2014 14:54:50 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id sc7si6461503vdc.85.2014.04.21.14.54.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 14:54:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so8791192veb.12 for ; Mon, 21 Apr 2014 14:54:50 -0700 (PDT) X-Received: by 10.58.187.9 with SMTP id fo9mr35732216vec.4.1398117290405; Mon, 21 Apr 2014 14:54:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp321052vcb; Mon, 21 Apr 2014 14:54:49 -0700 (PDT) X-Received: by 10.66.250.202 with SMTP id ze10mr4629791pac.153.1398117289481; Mon, 21 Apr 2014 14:54:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id td10si21518495pac.263.2014.04.21.14.54.48; Mon, 21 Apr 2014 14:54:48 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755231AbaDUVx1 (ORCPT + 26 others); Mon, 21 Apr 2014 17:53:27 -0400 Received: from mail-yk0-f170.google.com ([209.85.160.170]:63489 "EHLO mail-yk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754489AbaDUVxW (ORCPT ); Mon, 21 Apr 2014 17:53:22 -0400 Received: by mail-yk0-f170.google.com with SMTP id 9so3920419ykp.15 for ; Mon, 21 Apr 2014 14:53:21 -0700 (PDT) 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 Cc: bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;