mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
md: dm-zoned-target: Initialize return variable r to avoid uninitialized use
[ Upstream commit 487767bff5
]
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>
This commit is contained in:
parent
b0cab3d9c7
commit
d386c8e4e5
|
@ -1062,7 +1062,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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user