Skip to content

Commit 6c3593b

Browse files
committed
md: dm-zoned-target: Initialize return variable r to avoid uninitialized use
JIRA: https://issues.redhat.com/browse/RHEL-119009 Upstream Status: kernel/git/torvalds/linux.git commit 487767b Author: Purva Yeshi <purvayeshi550@gmail.com> Date: Thu Jul 10 13:11:57 2025 +0530 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> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
1 parent 77a95e0 commit 6c3593b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/dm-zoned-target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ static int dmz_iterate_devices(struct dm_target *ti,
10621062
struct dmz_target *dmz = ti->private;
10631063
unsigned int zone_nr_sectors = dmz_zone_nr_sectors(dmz->metadata);
10641064
sector_t capacity;
1065-
int i, r;
1065+
int i, r = 0;
10661066

10671067
for (i = 0; i < dmz->nr_ddevs; i++) {
10681068
capacity = dmz->dev[i].capacity & ~(zone_nr_sectors - 1);

0 commit comments

Comments
 (0)