]> 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:26:01 +0000 (16:26 +0200)
commitde012fce2c231434706fb09a89c7009154bad27d
tree34878150a1ac0229537f4ae3e7f48c954ffe45d8
parent7b2331beaa173b6f1e0653e3f56def7a521a12b7
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