* [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed
@ 2020-06-01 12:38 yu kuai
2020-06-02 7:37 ` Ming Lei
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: yu kuai @ 2020-06-01 12:38 UTC (permalink / raw)
To: axboe, ming.lei, martin.petersen, wenwen
Cc: linux-block, linux-kernel, yukuai3, yi.zhang
commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug") add a
kree() for 'buf' if bio_integrity_add_page() return '0'. However, the
object will be freed in bio_integrity_free() since 'bio->bi_opf' and
'bio->bi_integrity' was set previousy in bio_integrity_alloc().
Fixes: commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug")
Signed-off-by: yu kuai <yukuai3@huawei.com>
---
block/bio-integrity.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index bf62c25cde8f..ae07dd78e951 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -278,7 +278,6 @@ bool bio_integrity_prep(struct bio *bio)
if (ret == 0) {
printk(KERN_ERR "could not attach integrity payload\n");
- kfree(buf);
status = BLK_STS_RESOURCE;
goto err_end_io;
}
--
2.25.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed
2020-06-01 12:38 [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed yu kuai
@ 2020-06-02 7:37 ` Ming Lei
2020-06-02 8:01 ` Bob Liu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ming Lei @ 2020-06-02 7:37 UTC (permalink / raw)
To: yu kuai
Cc: axboe, martin.petersen, wenwen, linux-block, linux-kernel, yi.zhang
On Mon, Jun 01, 2020 at 08:38:56PM +0800, yu kuai wrote:
> commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug") add a
> kree() for 'buf' if bio_integrity_add_page() return '0'. However, the
> object will be freed in bio_integrity_free() since 'bio->bi_opf' and
> 'bio->bi_integrity' was set previousy in bio_integrity_alloc().
>
> Fixes: commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug")
> Signed-off-by: yu kuai <yukuai3@huawei.com>
> ---
> block/bio-integrity.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/block/bio-integrity.c b/block/bio-integrity.c
> index bf62c25cde8f..ae07dd78e951 100644
> --- a/block/bio-integrity.c
> +++ b/block/bio-integrity.c
> @@ -278,7 +278,6 @@ bool bio_integrity_prep(struct bio *bio)
>
> if (ret == 0) {
> printk(KERN_ERR "could not attach integrity payload\n");
> - kfree(buf);
> status = BLK_STS_RESOURCE;
> goto err_end_io;
> }
Looks correct, and it relies on the fact the 1st 'page' is always added
successfully, so 'buf' is always attached to the bip since then:
Reviewed-by: Ming Lei <ming.lei@redhat.com>
thanks,
Ming
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed
2020-06-01 12:38 [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed yu kuai
2020-06-02 7:37 ` Ming Lei
@ 2020-06-02 8:01 ` Bob Liu
2020-06-02 22:35 ` Martin K. Petersen
2020-06-02 22:44 ` Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Bob Liu @ 2020-06-02 8:01 UTC (permalink / raw)
To: yu kuai, axboe, ming.lei, martin.petersen, wenwen
Cc: linux-block, linux-kernel, yi.zhang
On 6/1/20 8:38 PM, yu kuai wrote:
> commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug") add a
> kree() for 'buf' if bio_integrity_add_page() return '0'. However, the
> object will be freed in bio_integrity_free() since 'bio->bi_opf' and
> 'bio->bi_integrity' was set previousy in bio_integrity_alloc().
>
> Fixes: commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug")
> Signed-off-by: yu kuai <yukuai3@huawei.com>> ---
> block/bio-integrity.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/block/bio-integrity.c b/block/bio-integrity.c
> index bf62c25cde8f..ae07dd78e951 100644
> --- a/block/bio-integrity.c
> +++ b/block/bio-integrity.c
> @@ -278,7 +278,6 @@ bool bio_integrity_prep(struct bio *bio)
>
> if (ret == 0) {
> printk(KERN_ERR "could not attach integrity payload\n");
> - kfree(buf);
> status = BLK_STS_RESOURCE;
> goto err_end_io;
> }
>
Looks good to me.
Reviewed-by: Bob Liu <bob.liu@oracle.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed
2020-06-01 12:38 [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed yu kuai
2020-06-02 7:37 ` Ming Lei
2020-06-02 8:01 ` Bob Liu
@ 2020-06-02 22:35 ` Martin K. Petersen
2020-06-02 22:44 ` Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2020-06-02 22:35 UTC (permalink / raw)
To: yu kuai
Cc: axboe, ming.lei, martin.petersen, wenwen, linux-block,
linux-kernel, yi.zhang
Hi Yu!
I suggest a few minor wording tweaks to the commit message:
> commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug") add
s/add/added/
> a kree() for 'buf' if bio_integrity_add_page() return '0'. However,
> the
s/kree/kfree/
s/return/returns/
> object will be freed in bio_integrity_free() since 'bio->bi_opf' and
> 'bio->bi_integrity' was set previousy in bio_integrity_alloc().
s/was/were/
Otherwise OK.
And like Ming pointed out, you may want to add a comment about the
assertion that the first vec is valid.
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed
2020-06-01 12:38 [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed yu kuai
` (2 preceding siblings ...)
2020-06-02 22:35 ` Martin K. Petersen
@ 2020-06-02 22:44 ` Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2020-06-02 22:44 UTC (permalink / raw)
To: yu kuai, ming.lei, martin.petersen, wenwen
Cc: linux-block, linux-kernel, yi.zhang
On 6/1/20 6:38 AM, yu kuai wrote:
> commit e7bf90e5afe3 ("block/bio-integrity: fix a memory leak bug") add a
> kree() for 'buf' if bio_integrity_add_page() return '0'. However, the
> object will be freed in bio_integrity_free() since 'bio->bi_opf' and
> 'bio->bi_integrity' was set previousy in bio_integrity_alloc().
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-06-02 22:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01 12:38 [PATCH] block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed yu kuai
2020-06-02 7:37 ` Ming Lei
2020-06-02 8:01 ` Bob Liu
2020-06-02 22:35 ` Martin K. Petersen
2020-06-02 22:44 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.