Skip to content

Commit 62611ab

Browse files
wensholtmann
authored andcommitted
Bluetooth: hci_bcm: Fix empty regulator supplies for Intel Macs
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: 75d1167 ("Bluetooth: hci_bcm: Add support for regulator supplies") Cc: <[email protected]> # 5.0.x Signed-off-by: Chen-Yu Tsai <[email protected]> Tested-by: Imre Kaloz <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent cd9151b commit 62611ab

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/bluetooth/hci_bcm.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,15 @@ static int bcm_gpio_set_power(struct bcm_device *dev, bool powered)
228228
int err;
229229

230230
if (powered && !dev->res_enabled) {
231-
err = regulator_bulk_enable(BCM_NUM_SUPPLIES, dev->supplies);
232-
if (err)
233-
return err;
231+
/* Intel Macs use bcm_apple_get_resources() and don't
232+
* have regulator supplies configured.
233+
*/
234+
if (dev->supplies[0].supply) {
235+
err = regulator_bulk_enable(BCM_NUM_SUPPLIES,
236+
dev->supplies);
237+
if (err)
238+
return err;
239+
}
234240

235241
/* LPO clock needs to be 32.768 kHz */
236242
err = clk_set_rate(dev->lpo_clk, 32768);
@@ -259,7 +265,13 @@ static int bcm_gpio_set_power(struct bcm_device *dev, bool powered)
259265
if (!powered && dev->res_enabled) {
260266
clk_disable_unprepare(dev->txco_clk);
261267
clk_disable_unprepare(dev->lpo_clk);
262-
regulator_bulk_disable(BCM_NUM_SUPPLIES, dev->supplies);
268+
269+
/* Intel Macs use bcm_apple_get_resources() and don't
270+
* have regulator supplies configured.
271+
*/
272+
if (dev->supplies[0].supply)
273+
regulator_bulk_disable(BCM_NUM_SUPPLIES,
274+
dev->supplies);
263275
}
264276

265277
/* wait for device to power on and come out of reset */

0 commit comments

Comments
 (0)