summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorPurva Yeshi <purvayeshi550@gmail.com>2025-07-10 13:11:57 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-20 18:30:46 +0200
commit167f7ba3a0b38b219c066077396d919ab2136f99 (patch)
treecb5b1ca0d28e05dd64731aaedff89b20675c9cfc /drivers/md
parentf8a9411ef145960bcd70bba106d7d6829dde28f8 (diff)
downloadlinux-167f7ba3a0b38b219c066077396d919ab2136f99.tar.gz
linux-167f7ba3a0b38b219c066077396d919ab2136f99.tar.bz2
linux-167f7ba3a0b38b219c066077396d919ab2136f99.zip
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>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-zoned-target.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 6141fc25d842..c38bd6e4c273 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -1061,7 +1061,7 @@ static int dmz_iterate_devices(struct dm_target *ti,
struct dmz_target *dmz = ti->private;
unsigned int zone_nr_sectors = dmz_zone_nr_sectors(dmz->metadata);
sector_t capacity;
- int i, r;
+ int i, r = 0;
for (i = 0; i < dmz->nr_ddevs; i++) {
capacity = dmz->dev[i].capacity & ~(zone_nr_sectors - 1);