Message ID | 20240116143437.89060-1-dmantipov@yandex.ru (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: bio-integrity: fix kcalloc() arguments order | expand |
On Tue, Jan 16, 2024 at 05:34:31PM +0300, Dmitry Antipov wrote: > When compiling with gcc version 14.0.1 20240116 (experimental) > and W=1, I've noticed the following warning: > > block/bio-integrity.c: In function 'bio_integrity_map_user': > block/bio-integrity.c:339:38: warning: 'kcalloc' sizes specified with 'sizeof' > in the earlier argument and not in the later argument [-Wcalloc-transposed-args] > 339 | bvec = kcalloc(sizeof(*bvec), nr_vecs, GFP_KERNEL); > | ^ > block/bio-integrity.c:339:38: note: earlier argument should specify number of > elements, later size of each element > > Since 'n' and 'size' arguments of 'kcalloc()' are multiplied to > calculate the final size, their actual order doesn't affect the > result and so this is not a bug. But it's still worth to fix it. > > Fixes: 492c5d455969 ("block: bio-integrity: directly map user buffers") Looks good. Reviewed-by: Keith Busch <kbusch@kernel.org>
On Tue, 16 Jan 2024 17:34:31 +0300, Dmitry Antipov wrote: > When compiling with gcc version 14.0.1 20240116 (experimental) > and W=1, I've noticed the following warning: > > block/bio-integrity.c: In function 'bio_integrity_map_user': > block/bio-integrity.c:339:38: warning: 'kcalloc' sizes specified with 'sizeof' > in the earlier argument and not in the later argument [-Wcalloc-transposed-args] > 339 | bvec = kcalloc(sizeof(*bvec), nr_vecs, GFP_KERNEL); > | ^ > block/bio-integrity.c:339:38: note: earlier argument should specify number of > elements, later size of each element > > [...] Applied, thanks! [1/1] block: bio-integrity: fix kcalloc() arguments order commit: be50df31c4e2a69f961a3bb759346d299eaa2b23 Best regards,
diff --git a/block/bio-integrity.c b/block/bio-integrity.c index feef615e2c9c..c9a16fba58b9 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -336,7 +336,7 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, if (nr_vecs > BIO_MAX_VECS) return -E2BIG; if (nr_vecs > UIO_FASTIOV) { - bvec = kcalloc(sizeof(*bvec), nr_vecs, GFP_KERNEL); + bvec = kcalloc(nr_vecs, sizeof(*bvec), GFP_KERNEL); if (!bvec) return -ENOMEM; pages = NULL;
When compiling with gcc version 14.0.1 20240116 (experimental) and W=1, I've noticed the following warning: block/bio-integrity.c: In function 'bio_integrity_map_user': block/bio-integrity.c:339:38: warning: 'kcalloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 339 | bvec = kcalloc(sizeof(*bvec), nr_vecs, GFP_KERNEL); | ^ block/bio-integrity.c:339:38: note: earlier argument should specify number of elements, later size of each element Since 'n' and 'size' arguments of 'kcalloc()' are multiplied to calculate the final size, their actual order doesn't affect the result and so this is not a bug. But it's still worth to fix it. Fixes: 492c5d455969 ("block: bio-integrity: directly map user buffers") Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> --- block/bio-integrity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)