diff options
author | Mike Snitzer <snitzer@kernel.org> | 2022-07-05 23:12:27 +0300 |
---|---|---|
committer | Mike Snitzer <snitzer@kernel.org> | 2022-07-07 18:49:34 +0300 |
commit | 564b5c5476cdb71b717340897b2b50f9c45df158 (patch) | |
tree | 75ff585908371d35a6142b3c8b9612c1cb8ac3a4 /drivers/md/dm-core.h | |
parent | 2aec377a29250b942f14d3c16d49783da3e9df11 (diff) | |
download | linux-564b5c5476cdb71b717340897b2b50f9c45df158.tar.xz |
dm table: audit all dm_table_get_target() callers
All callers of dm_table_get_target() are expected to do proper bounds
checking on the index they pass.
Move dm_table_get_target() to dm-core.h to make it extra clear that only
DM core code should be using it. Switch it to be inlined while at it.
Standardize all DM core callers to use the same for loop pattern and
make associated variables as local as possible. Rename some variables
(e.g. s/table/t/ and s/tgt/ti/) along the way.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Diffstat (limited to 'drivers/md/dm-core.h')
-rw-r--r-- | drivers/md/dm-core.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 8ef780a6baae..6c6bd24774f2 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -226,6 +226,13 @@ struct dm_table { #endif }; +static inline struct dm_target *dm_table_get_target(struct dm_table *t, + unsigned int index) +{ + BUG_ON(index >= t->num_targets); + return t->targets + index; +} + /* * One of these is allocated per clone bio. */ |