]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:28:28 +0000 (16:28 +0200)
commitd386c8e4e587c910b97caee9bd25732729bd7ed3
tree20704bfae76903b8c04b436bddc3eae622a7decc
parentb0cab3d9c70d67fd91c7366be1aa8905c4474956
md: dm-zoned-target: Initialize return variable r to avoid uninitialized use

[ Upstream commit 487767bff572d46f7c37ad846c4078f6d6c9cc55 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/dm-zoned-target.c