* [PATCH] dm-bufio: use kzalloc_flex
@ 2026-03-26 4:13 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-03-26 4:13 UTC (permalink / raw)
To: dm-devel
Cc: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
Benjamin Marzinski, Kees Cook, Gustavo A. R. Silva, open list,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
Avoid manual size calculations and use the proper helper.
Add __counted_by for extra runtime analysis.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/md/dm-bufio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 60f7badec91f..26fedf5883ef 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -391,7 +391,7 @@ struct dm_buffer_cache {
*/
unsigned int num_locks;
bool no_sleep;
- struct buffer_tree trees[];
+ struct buffer_tree trees[] __counted_by(num_locks);
};
static DEFINE_STATIC_KEY_FALSE(no_sleep_enabled);
@@ -2511,7 +2511,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
}
num_locks = dm_num_hash_locks();
- c = kzalloc(sizeof(*c) + (num_locks * sizeof(struct buffer_tree)), GFP_KERNEL);
+ c = kzalloc_flex(*c, cache.trees, num_locks);
if (!c) {
r = -ENOMEM;
goto bad_client;
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-26 4:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 4:13 [PATCH] dm-bufio: use kzalloc_flex Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox