Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] block/bio-integrity: use struct_size() in kmalloc()
@ 2019-05-15  8:52 Jackie Liu
  2019-05-15 15:50 ` Chaitanya Kulkarni
  2019-05-16 14:49 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Jackie Liu @ 2019-05-15  8:52 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Jackie Liu

Use the new struct_size() helper to keep code simple.

Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 block/bio-integrity.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 1b633a3526d4..5152009b5b59 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -57,8 +57,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
 	unsigned inline_vecs;
 
 	if (!bs || !mempool_initialized(&bs->bio_integrity_pool)) {
-		bip = kmalloc(sizeof(struct bio_integrity_payload) +
-			      sizeof(struct bio_vec) * nr_vecs, gfp_mask);
+		bip = kmalloc(struct_size(bip, bip_inline_vecs, nr_vecs), gfp_mask);
 		inline_vecs = nr_vecs;
 	} else {
 		bip = mempool_alloc(&bs->bio_integrity_pool, gfp_mask);
-- 
2.21.0




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block/bio-integrity: use struct_size() in kmalloc()
  2019-05-15  8:52 [PATCH] block/bio-integrity: use struct_size() in kmalloc() Jackie Liu
@ 2019-05-15 15:50 ` Chaitanya Kulkarni
  2019-05-16 14:49 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-15 15:50 UTC (permalink / raw)
  To: Jackie Liu, axboe; +Cc: linux-block

Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 05/15/2019 02:04 AM, Jackie Liu wrote:
> Use the new struct_size() helper to keep code simple.
>
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
>   block/bio-integrity.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/block/bio-integrity.c b/block/bio-integrity.c
> index 1b633a3526d4..5152009b5b59 100644
> --- a/block/bio-integrity.c
> +++ b/block/bio-integrity.c
> @@ -57,8 +57,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
>   	unsigned inline_vecs;
>
>   	if (!bs || !mempool_initialized(&bs->bio_integrity_pool)) {
> -		bip = kmalloc(sizeof(struct bio_integrity_payload) +
> -			      sizeof(struct bio_vec) * nr_vecs, gfp_mask);
> +		bip = kmalloc(struct_size(bip, bip_inline_vecs, nr_vecs), gfp_mask);
>   		inline_vecs = nr_vecs;
>   	} else {
>   		bip = mempool_alloc(&bs->bio_integrity_pool, gfp_mask);
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block/bio-integrity: use struct_size() in kmalloc()
  2019-05-15  8:52 [PATCH] block/bio-integrity: use struct_size() in kmalloc() Jackie Liu
  2019-05-15 15:50 ` Chaitanya Kulkarni
@ 2019-05-16 14:49 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2019-05-16 14:49 UTC (permalink / raw)
  To: Jackie Liu; +Cc: linux-block

On 5/15/19 2:52 AM, Jackie Liu wrote:
> Use the new struct_size() helper to keep code simple.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15  8:52 [PATCH] block/bio-integrity: use struct_size() in kmalloc() Jackie Liu
2019-05-15 15:50 ` Chaitanya Kulkarni
2019-05-16 14:49 ` Jens Axboe

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org linux-block@archiver.kernel.org
	public-inbox-index linux-block


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/ public-inbox