Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1171997yba; Thu, 9 May 2019 11:57:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+NIOil4O8m7OHOULeMxhxW546xSIwZl/tky4LMQh6yyjc3/s4Uy0EihgTm2D5HYNcKXEW X-Received: by 2002:a63:243:: with SMTP id 64mr7774886pgc.214.1557428272061; Thu, 09 May 2019 11:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557428272; cv=none; d=google.com; s=arc-20160816; b=mahfQJqaGRg2gKsdCknZlwkJhSvCmbzYNUhGs0juhMDW7pUtzWw5d/VLkCd2BMmZjw 7Tj4mf1RsqYLnEkY8kutUTSw2Ql7dWyuOpSgX2wH7gjE/gQVR3tw4bJHJGvmk7s9CLZG k0SHC1IAj7nBNMXV2ZvIufV6l3irMRF00gp01dnsuyRcVkIQLdkspa8AeaAEh1meWVoE Gx9O/ZjBu84lhWBy7SebRWoCmHHYvAIdmXwAlIThfL5FHnoan0ocKFvKPVwMuUZEBt+D A6567lmSB06HLPdBbwBK6rBbFKGsW3jM/AWW7KWm9nx6QXClOHO2PCoMs+0hs9roDMlL kosA== 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:dkim-signature; bh=3D/o5Fm30CJqilRMhjSw6WRd3AX+quAKMqSdle+u6so=; b=jRWDlgVxHdu4GlGx+H0dYRbKZc/KhY8Qdfgzol+5sQWKhI/2pAqFOt4B7YruqkkWtj yZQOCAMjGYuwogo2CRtbmMKN1Ibeoqg+0T5rer82Xaqo8dBorAmCmsKKfRar2BCbpgHw vp0Kyz7tTpZf3c7zYWIKUAjwslwOjnm3wdD8y2TMFxOE8SsMRh1IsDBsPI4ix2tNsQwk WMWFpPIOL7IxNV6j5MRzl6NQ8B4DCA4PuApb17Mcp9ztewUCBH5gUScIyF877Ld4T13G +XWplP+SiySbpftdkZ61ruvrufs2m6lDKuSJYjUL8nUmLfOLZz+s8NKfgjcn+Ar/C1J8 0G3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OcFJOTUY; 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 z14si4406367pgs.556.2019.05.09.11.57.35; Thu, 09 May 2019 11:57:52 -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; dkim=pass header.i=@kernel.org header.s=default header.b=OcFJOTUY; 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 S1729266AbfEISzj (ORCPT + 99 others); Thu, 9 May 2019 14:55:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:50712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729258AbfEISzh (ORCPT ); Thu, 9 May 2019 14:55:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E9429217D6; Thu, 9 May 2019 18:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557428136; bh=g85WHPlSeeNCZmBZ0LD/EXxEDcEyzF+M+UOePGG4gEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OcFJOTUY7RNhcOQJ+1fGIg3M22b+9lg1IKbxfo+djqO8dJiKjruSglBAqAQZR1u+a JYj8nP5Enk87yGpneSeu1+ia75WFzL+UWTRIUJpjkqrakHtTkneCyG38AjlTRoJ53e lCoNQMzQ2t3FZ73R+2xv9ZBVuIFIl+CWrJov3xsc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen-Yu Tsai , Imre Kaloz , Marcel Holtmann Subject: [PATCH 5.1 25/30] Bluetooth: hci_bcm: Fix empty regulator supplies for Intel Macs Date: Thu, 9 May 2019 20:42:57 +0200 Message-Id: <20190509181256.346176831@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190509181250.417203112@linuxfoundation.org> References: <20190509181250.417203112@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Chen-Yu Tsai commit 62611abc8f37d00e3b0cff0eb2d72fa92b05fd27 upstream. The code path for Macs goes through bcm_apple_get_resources(), which skips over the code that sets up the regulator supplies. As a result, the call to regulator_bulk_enable() / regulator_bulk_disable() results in a NULL pointer dereference. This was reported on the kernel.org Bugzilla, bug 202963. Unbreak Broadcom Bluetooth support on Intel Macs by checking if the supplies were set up before enabling or disabling them. The same does not need to be done for the clocks, as the common clock framework API checks for NULL pointers. Fixes: 75d11676dccb ("Bluetooth: hci_bcm: Add support for regulator supplies") Cc: # 5.0.x Signed-off-by: Chen-Yu Tsai Tested-by: Imre Kaloz Signed-off-by: Marcel Holtmann Signed-off-by: Greg Kroah-Hartman --- drivers/bluetooth/hci_bcm.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -228,9 +228,15 @@ static int bcm_gpio_set_power(struct bcm int err; if (powered && !dev->res_enabled) { - err = regulator_bulk_enable(BCM_NUM_SUPPLIES, dev->supplies); - if (err) - return err; + /* Intel Macs use bcm_apple_get_resources() and don't + * have regulator supplies configured. + */ + if (dev->supplies[0].supply) { + err = regulator_bulk_enable(BCM_NUM_SUPPLIES, + dev->supplies); + if (err) + return err; + } /* LPO clock needs to be 32.768 kHz */ err = clk_set_rate(dev->lpo_clk, 32768); @@ -259,7 +265,13 @@ static int bcm_gpio_set_power(struct bcm if (!powered && dev->res_enabled) { clk_disable_unprepare(dev->txco_clk); clk_disable_unprepare(dev->lpo_clk); - regulator_bulk_disable(BCM_NUM_SUPPLIES, dev->supplies); + + /* Intel Macs use bcm_apple_get_resources() and don't + * have regulator supplies configured. + */ + if (dev->supplies[0].supply) + regulator_bulk_disable(BCM_NUM_SUPPLIES, + dev->supplies); } /* wait for device to power on and come out of reset */