diff mbox series

raid1: fix incorrect page freeing in alloc_behind_master_bio

Message ID 20230605072114.497609-1-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series raid1: fix incorrect page freeing in alloc_behind_master_bio | expand

Commit Message

Christoph Hellwig June 5, 2023, 7:21 a.m. UTC
free_page takes the virtual address of the memory to be freed, and
does so as an unsigned long just to make things confusing.  Use
put_page instead, which actually works on the page pointer.

Note that this is a reason why this should have used __bio_add_page
instead for this impossible to hit case..

Fixes: 2f9848178cfa ("md: raid1: use __bio_add_page for adding single page to bio")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/raid1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johannes Thumshirn June 5, 2023, 7:58 a.m. UTC | #1
On 05.06.23 09:21, Christoph Hellwig wrote:
> free_page takes the virtual address of the memory to be freed, and
> does so as an unsigned long just to make things confusing.  Use
> put_page instead, which actually works on the page pointer.
> 
> Note that this is a reason why this should have used __bio_add_page
> instead for this impossible to hit case..
> 
> Fixes: 2f9848178cfa ("md: raid1: use __bio_add_page for adding single page to bio")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/md/raid1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index ff89839455ec11..3570da63969b58 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -1148,7 +1148,7 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio,
>  			goto free_pages;
>  
>  		if (!bio_add_page(behind_bio, page, len, 0)) {
> -			free_page(page);
> +			put_page(page);
>  			goto free_pages;
>  		}
>  

That should already be fixed in Jens' tree.
diff mbox series

Patch

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ff89839455ec11..3570da63969b58 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1148,7 +1148,7 @@  static void alloc_behind_master_bio(struct r1bio *r1_bio,
 			goto free_pages;
 
 		if (!bio_add_page(behind_bio, page, len, 0)) {
-			free_page(page);
+			put_page(page);
 			goto free_pages;
 		}