]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dm zoned: fix potential NULL dereference in dmz_do_reclaim()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Aug 2019 09:58:14 +0000 (12:58 +0300)
committerMike Snitzer <snitzer@redhat.com>
Wed, 21 Aug 2019 15:29:30 +0000 (11:29 -0400)
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: 160c1004c5a9 ("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>
drivers/md/dm-zoned-metadata.c

index 2a5bc51fd6d53bfee2e0097b6f3a81b0761cb22b..595a73110e1731efbabd33e14c0f4ec2401da4d8 100644 (file)
@@ -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)
@@ -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);
 }
 
 /*