Skip to content

Commit

Permalink
dm zoned: fix potential NULL dereference in dmz_do_reclaim()
Browse files Browse the repository at this point in the history
This function is supposed to return error pointers so it matches the
dmz_get_rnd_zone_for_reclaim() function.  The current code could lead to
a NULL dereference in dmz_do_reclaim()

Fixes: b234c6d ("dm zoned: improve error handling in reclaim")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Dan Carpenter authored and snitm committed Aug 21, 2019
1 parent 08c04c8 commit e0702d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/md/dm-zoned-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd)
struct dm_zone *zone;

if (list_empty(&zmd->map_seq_list))
return NULL;
return ERR_PTR(-EBUSY);

list_for_each_entry(zone, &zmd->map_seq_list, link) {
if (!zone->bzone)
Expand All @@ -1597,7 +1597,7 @@ static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd)
return zone;
}

return NULL;
return ERR_PTR(-EBUSY);
}

/*
Expand Down

0 comments on commit e0702d9

Please sign in to comment.