md: dm-zoned-target: Initialize return variable r to avoid uninitialized use
authorPurva Yeshi <purvayeshi550@gmail.com>
Thu, 10 Jul 2025 07:41:57 +0000 (13:11 +0530)
committerMikulas Patocka <mpatocka@redhat.com>
Thu, 31 Jul 2025 13:39:55 +0000 (15:39 +0200)
commit487767bff572d46f7c37ad846c4078f6d6c9cc55
tree7fbad5e94d526f5f291418c28ecd7a390c0732da
parentbdf253d580d7d30e7620844c63a5013fe7ba3f87
md: dm-zoned-target: Initialize return variable r to avoid uninitialized use

Fix Smatch-detected error:
drivers/md/dm-zoned-target.c:1073 dmz_iterate_devices()
error: uninitialized symbol 'r'.

Smatch detects a possible use of the uninitialized variable 'r' in
dmz_iterate_devices() because if dmz->nr_ddevs is zero, the loop is
skipped and 'r' is returned without being set, leading to undefined
behavior.

Initialize 'r' to 0 before the loop. This ensures that if there are no
devices to iterate over, the function still returns a defined value.

Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-zoned-target.c