Message ID | 20241031-bluetooth-btbcm-node-cleanup-v2-1-482d52910bfa@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 6ef8bb9d0bd632e0ea2b7b3393b3b9256964249d |
Headers | show |
Series | [v2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name() | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/CheckPatch | success | CheckPatch PASS |
tedd_an/GitLint | fail | WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 18: B1 Line exceeds max length (105>80): "- Link to v1: https://lore.kernel.org/r/20241030-bluetooth-btbcm-node-cleanup-v1-0-fdc4b9df9fe3@gmail.com" |
tedd_an/SubjectPrefix | success | Gitlint PASS |
tedd_an/BuildKernel | success | BuildKernel PASS |
tedd_an/CheckAllWarning | success | CheckAllWarning PASS |
tedd_an/CheckSparse | success | CheckSparse PASS |
Hello: This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>: On Thu, 31 Oct 2024 13:11:23 +0100 you wrote: > of_find_node_by_path() returns a pointer to a device_node with its > refcount incremented, and a call to of_node_put() is required to > decrement the refcount again and avoid leaking the resource. > > If 'of_property_read_string_index(root, "compatible", 0, &tmp)' fails, > the function returns without calling of_node_put(root) before doing so. > > [...] Here is the summary with links: - [v2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name() https://git.kernel.org/bluetooth/bluetooth-next/c/6ef8bb9d0bd6 You are awesome, thank you!
diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c index eef00467905e..a1153ada74d2 100644 --- a/drivers/bluetooth/btbcm.c +++ b/drivers/bluetooth/btbcm.c @@ -541,11 +541,10 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = { static const char *btbcm_get_board_name(struct device *dev) { #ifdef CONFIG_OF - struct device_node *root; + struct device_node *root __free(device_node) = of_find_node_by_path("/"); char *board_type; const char *tmp; - root = of_find_node_by_path("/"); if (!root) return NULL; @@ -555,7 +554,6 @@ static const char *btbcm_get_board_name(struct device *dev) /* get rid of any '/' in the compatible string */ board_type = devm_kstrdup(dev, tmp, GFP_KERNEL); strreplace(board_type, '/', '-'); - of_node_put(root); return board_type; #else
of_find_node_by_path() returns a pointer to a device_node with its refcount incremented, and a call to of_node_put() is required to decrement the refcount again and avoid leaking the resource. If 'of_property_read_string_index(root, "compatible", 0, &tmp)' fails, the function returns without calling of_node_put(root) before doing so. The automatic cleanup attribute can be used by means of the __free() macro to automatically call of_node_put() when the variable goes out of scope, fixing the issue and also accounting for new error paths. Fixes: 63fac3343b99 ("Bluetooth: btbcm: Support per-board firmware variants") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> --- Changes in v2: - Squash patches for mainline solution without intermediate steps. - Link to v1: https://lore.kernel.org/r/20241030-bluetooth-btbcm-node-cleanup-v1-0-fdc4b9df9fe3@gmail.com --- drivers/bluetooth/btbcm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- base-commit: 6fb2fa9805c501d9ade047fc511961f3273cdcb5 change-id: 20241030-bluetooth-btbcm-node-cleanup-23d21a73870c Best regards,