Re: [PATCH] w1: ds2490: bound the search results to the found_ids array

From: Krzysztof Kozlowski

Date: Tue Nov 17 2026 - 09:58:42 EST


On 17/11/2026 15:55, Maoyi Xie wrote:
> ds9490r_search() queues the ids from the DS2490 in found_ids, which has
> max_slave_count entries. max_slave_count is also the search limit. With
> more devices than that on the bus, the DS2490 sends that many ids and
> then a discrepancy value, as the comment in the function says.
>
> The break at the limit leaves the loop over the current bulk read, but
> the outer loop keeps reading until the device is idle. A discrepancy
> value in a later bulk read is then stored in found_ids[max_slave_count],
> one past the end, and the callback loop reads it back as an id. If the
> device sends more values, they are written past the array too.
>
> Store an id only if it fits and pass at most max_slave_count ids to the
> callback. found can still reach max_slave_count + 1, so the check after
> the loop sees that more devices remain. Use one local copy of
> max_slave_count for the allocation and the bound.
>
> I found this with a static analysis tool that we are developing. A

LLM is not static analysis.

Just say you use Claude or other LLM in changelog, not commit msg.


> userspace harness runs an unmodified copy of ds9490r_search() from
> v7.4-rc3 against a fake DS2490. With the default max_slave_count of 64,

You need to test linux-next. There were several fixes for w1 recently.

Best regards,
Krzysztof