Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

slimbus: core: check get_addr before removing laddr ida

logical address can be either assigned by the SLIMBus controller or the core.
Core uses IDA in cases where get_addr callback is not provided by the
controller.
Core already has this check while allocating IDR, however during absence
reporting this is not checked. This patch fixes this issue.

Fixes: 46a2bb5a7f7e ("slimbus: core: Add slim controllers support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20200925095520.27316-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Srinivas Kandagatla and committed by
Greg Kroah-Hartman
f97769fd 5a487cf7

+2 -2
+2 -2
drivers/slimbus/core.c
··· 326 326 mutex_lock(&ctrl->lock); 327 327 sbdev->is_laddr_valid = false; 328 328 mutex_unlock(&ctrl->lock); 329 - 330 - ida_simple_remove(&ctrl->laddr_ida, sbdev->laddr); 329 + if (!ctrl->get_laddr) 330 + ida_simple_remove(&ctrl->laddr_ida, sbdev->laddr); 331 331 slim_device_update_status(sbdev, SLIM_DEVICE_STATUS_DOWN); 332 332 } 333 333 EXPORT_SYMBOL_GPL(slim_report_absent);