Project

General

Profile

Actions

Bug #486

open

dat: incorrect documentation for batadv_dat_select_candidates/batadv_is_orig_node_eligible

Added by Sven Eckelmann 15 days ago.

Status:
New
Priority:
Normal
Target version:
-
Start date:
10/31/2026
Due date:
% Done:

0%

Estimated time:

Description

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261030135105.2555887-1-sw%40simonwunderlich.de?part=5

--- Patch [5]: [PATCH net 05/14] batman-adv: dat: initialize orig_node of unfilled candidate slots ---
commit 1d31b386a9fc6030d298b315a9725cc7d1515170
Author: Sven Eckelmann <sven@narfation.org>

batman-adv: dat: initialize orig_node of unfilled candidate slots

batadv_choose_next_candidate() now clears cands[select].orig_node along
with setting the slot to BATADV_DAT_CANDIDATE_NOT_FOUND. Before this,
batadv_is_orig_node_eligible() could read an uninitialized orig_node from
earlier slots that had no candidate.

Closes: https://sashiko.dev/#/bug/linux-b25d9aa4-10bb-427c-a145-ccaadc2a1bb9

> diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
> index 74050bffedbce..0260ed7e828b2 100644
> --- a/net/batman-adv/distributed-arp-table.c
> +++ b/net/batman-adv/distributed-arp-table.c
> @@ -653,6 +653,7 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
>       * NOT_FOUND
>       */
>      cands[select].type = BATADV_DAT_CANDIDATE_NOT_FOUND;
> +    cands[select].orig_node = NULL;
>  
>      /* iterate over the originator list and find the node with the closest
>       * dat_address which has not been selected yet

Discovered by: opus-5-5, opus-5 · Missed by: fable-5-1, gpt-6-astra · Called a false positive by: gpt-6-astra
This is a pre-existing issue, and this patch did not introduce it. Two
kernel-doc comments next to this fix don't match the code.

The kernel-doc for batadv_dat_select_candidates() says:

 * Return: the candidate array of size BATADV_DAT_CANDIDATE_NUM.

No macro by that name exists. The allocation and the loop in that
function both use BATADV_DAT_CANDIDATES_NUM, which net/batman-adv/main.h
defines:

    #define BATADV_DAT_CANDIDATES_NUM 3

Should the comment say BATADV_DAT_CANDIDATES_NUM?

Also, the kernel-doc for batadv_is_orig_node_eligible() describes the
parameter like this:

 * @max_orig_node: last selected candidate

The value passed in is the local max_orig_node from
batadv_choose_next_candidate(). That is the best candidate found so far
in the current round, and it is only used for the tie-break:

    if (tmp_max == max && max_orig_node &&
        memcmp(candidate->orig, max_orig_node->orig, ETH_ALEN) >= 0)
        goto out;

Candidates that were already selected are checked separately through
res[j].orig_node.

Would a description like "current round's best candidate so far" be
more accurate here?

No data to display

Actions

Also available in: Atom PDF