Commit 511ba402 authored by Purva Yeshi's avatar Purva Yeshi Committed by Greg Kroah-Hartman
Browse files

md: dm-zoned-target: Initialize return variable r to avoid uninitialized use



[ Upstream commit 487767bf ]

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: default avatarPurva Yeshi <purvayeshi550@gmail.com>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 3eaf16ff
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment