mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 6.1] scsi: ufs: ufshpb: Fix NULL deallocation in ufshpb_pre_req_mempool_destroy()
@ 2024-07-03 11:17 Aleksandr Mishin
  2024-07-03 19:11 ` Bart Van Assche
  0 siblings, 1 reply; 2+ messages in thread
From: Aleksandr Mishin @ 2024-07-03 11:17 UTC (permalink / raw)
  To: Daejun Park, stable, Greg Kroah-Hartman
  Cc: Aleksandr Mishin, Alim Akhtar, Avri Altman, Bart Van Assche,
	James E.J. Bottomley, Martin K. Petersen, Can Guo, Bean Huo,
	linux-scsi, linux-kernel, lvc-project

No upstream commit exists for this commit.

The issue was introduced with commit 41d8a9333cc9 ("scsi: ufs: ufshpb:
Add HPB 2.0 support").

In ufshpb_pre_req_mempool_destroy() __free_page() is called only if pointer
contains NULL value.
Fix this bug by modifying check condition.

Upstream branch code has been significantly refactored and can't be
backported directly.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 41d8a9333cc9 ("scsi: ufs: ufshpb: Add HPB 2.0 support")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
 drivers/ufs/core/ufshpb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufshpb.c b/drivers/ufs/core/ufshpb.c
index b7f412d0f301..c649e8a10a23 100644
--- a/drivers/ufs/core/ufshpb.c
+++ b/drivers/ufs/core/ufshpb.c
@@ -2120,7 +2120,7 @@ static void ufshpb_pre_req_mempool_destroy(struct ufshpb_lu *hpb)
 	for (i = 0; i < hpb->throttle_pre_req; i++) {
 		pre_req = hpb->pre_req + i;
 		bio_put(hpb->pre_req[i].bio);
-		if (!pre_req->wb.m_page)
+		if (pre_req->wb.m_page)
 			__free_page(hpb->pre_req[i].wb.m_page);
 		list_del_init(&pre_req->list_req);
 	}
-- 
2.30.2


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

* Re: [PATCH 6.1] scsi: ufs: ufshpb: Fix NULL deallocation in ufshpb_pre_req_mempool_destroy()
  2024-07-03 11:17 [PATCH 6.1] scsi: ufs: ufshpb: Fix NULL deallocation in ufshpb_pre_req_mempool_destroy() Aleksandr Mishin
@ 2024-07-03 19:11 ` Bart Van Assche
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2024-07-03 19:11 UTC (permalink / raw)
  To: Aleksandr Mishin, Daejun Park, stable, Greg Kroah-Hartman
  Cc: Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Can Guo, Bean Huo, linux-scsi, linux-kernel,
	lvc-project

On 7/3/24 4:17 AM, Aleksandr Mishin wrote:
> No upstream commit exists for this commit.
> 
> The issue was introduced with commit 41d8a9333cc9 ("scsi: ufs: ufshpb:
> Add HPB 2.0 support").
> 
> In ufshpb_pre_req_mempool_destroy() __free_page() is called only if pointer
> contains NULL value.
> Fix this bug by modifying check condition.
> 
> Upstream branch code has been significantly refactored and can't be
> backported directly.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 41d8a9333cc9 ("scsi: ufs: ufshpb: Add HPB 2.0 support")
> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
> ---
>   drivers/ufs/core/ufshpb.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufshpb.c b/drivers/ufs/core/ufshpb.c
> index b7f412d0f301..c649e8a10a23 100644
> --- a/drivers/ufs/core/ufshpb.c
> +++ b/drivers/ufs/core/ufshpb.c
> @@ -2120,7 +2120,7 @@ static void ufshpb_pre_req_mempool_destroy(struct ufshpb_lu *hpb)
>   	for (i = 0; i < hpb->throttle_pre_req; i++) {
>   		pre_req = hpb->pre_req + i;
>   		bio_put(hpb->pre_req[i].bio);
> -		if (!pre_req->wb.m_page)
> +		if (pre_req->wb.m_page)
>   			__free_page(hpb->pre_req[i].wb.m_page);
>   		list_del_init(&pre_req->list_req);
>   	}

Are any users of the 6.1 kernel using UFS HPB support? If not, another
possibility is to backport commit 7e9609d2daea ("scsi: ufs: core: Remove
HPB support").

Thanks,

Bart.

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

end of thread, other threads:[~2024-07-03 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-03 11:17 [PATCH 6.1] scsi: ufs: ufshpb: Fix NULL deallocation in ufshpb_pre_req_mempool_destroy() Aleksandr Mishin
2024-07-03 19:11 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®