]> git.baikalelectronics.ru Git - kernel.git/commit
Bluetooth: hci_qca: Fix an error pointer dereference
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 29 May 2020 09:59:48 +0000 (12:59 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 3 Jun 2020 17:55:33 +0000 (19:55 +0200)
commitb23ff3bfe061a6d64c526409f672ff7d9f8c9562
tree071539ee304faaa2c20ea2391cda92461709d805
parent72db05d3770f068b0e9d395b8f6379f551388b13
Bluetooth: hci_qca: Fix an error pointer dereference

When a function like devm_clk_get_optional() function returns both error
pointers on error and NULL then the NULL return means that the optional
feature is deliberately disabled.  It is a special sort of success and
should not trigger an error message.  The surrounding code should be
written to check for NULL and not crash.

On the other hand, if we encounter an error, then the probe from should
clean up and return a failure.

In this code, if devm_clk_get_optional() returns an error pointer then
the kernel will crash inside the call to:

clk_set_rate(qcadev->susclk, SUSCLK_RATE_32KHZ);

The error handling must be updated to prevent that.

Fixes: a9a483f28f5f ("Bluetooth: hci_qca: Replace devm_gpiod_get() with devm_gpiod_get_optional()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_qca.c