• Dan Carpenter's avatar
    Bluetooth: hci_qca: Fix an error pointer dereference · 4c07a5d7
    Dan Carpenter authored
    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: 77131dfe ("Bluetooth: hci_qca: Replace devm_gpiod_get() with devm_gpiod_get_optional()")
    Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
    4c07a5d7
hci_qca.c 54.9 KB