Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sinan Kaya <Okaya@kernel.org>
To: Eugen Hristev <eugen.hristev@linaro.org>,
	Qasim Ijaz <qasdev00@gmail.com>, Vinod Koul <vkoul@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH 2/2] dmaengine: qcom_hidma: fix handoff FIFO memory leak on driver removal
Date: Fri, 6 Jun 2025 09:35:44 -0400	[thread overview]
Message-ID: <7649f016-87f1-475d-8ff7-7608b14c5654@kernel.org> (raw)
In-Reply-To: <3c6513fe-83b3-4117-8df6-6f8c7eb07303@linaro.org>


On 6/5/2025 9:04 AM, Eugen Hristev wrote:
>> diff --git a/drivers/dma/qcom/hidma_ll.c b/drivers/dma/qcom/hidma_ll.c
>> index fee448499777..0c2bae46746c 100644
>> --- a/drivers/dma/qcom/hidma_ll.c
>> +++ b/drivers/dma/qcom/hidma_ll.c
>> @@ -816,6 +816,7 @@ int hidma_ll_uninit(struct hidma_lldev *lldev)
>>   
>>   	required_bytes = sizeof(struct hidma_tre) * lldev->nr_tres;
>>   	tasklet_kill(&lldev->task);
>> +	kfifo_free(&lldev->handoff_fifo);
>>   	memset(lldev->trepool, 0, required_bytes);
>>   	lldev->trepool = NULL;
>>   	atomic_set(&lldev->pending_tre_count, 0);
> Is it possible that the handoff_fifo is freed, then we could observe
> reset complete interrupts before they are being cleared in
> hidma_ll_uninit later on, which would lead to the following call chain
>
>   hidma_ll_inthandler - hidma_ll_int_handler_internal -
> hidma_handle_tre_completion - hidma_post_completed -
> tasklet_schedule(&lldev->task); - hidma_ll_tre_complete - kfifo_out

According to the documentation, the way to guarantee this from not happening

is to call tasklet_disable() to ensure that tasklet completes execution. 
Only after that

data structures used by the tasklet can be freed.

I think proper order is:

1. tasklet_disable

2. tasklet_kill

3. kfifo_free




  reply	other threads:[~2025-06-06 13:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250601224231.24317-1-qasdev00@gmail.com>
2025-06-01 22:42 ` [PATCH 1/2] dmaengine: qcom_hidma: fix memory leak on probe failure Qasim Ijaz
2025-06-05 13:06   ` Eugen Hristev
2025-06-01 22:42 ` [PATCH 2/2] dmaengine: qcom_hidma: fix handoff FIFO memory leak on driver removal Qasim Ijaz
2025-06-05 13:04   ` Eugen Hristev
2025-06-06 13:35     ` Sinan Kaya [this message]
2025-06-15 19:15       ` Qasim Ijaz
2025-06-16 21:59         ` Sinan Kaya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7649f016-87f1-475d-8ff7-7608b14c5654@kernel.org \
    --to=okaya@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=eugen.hristev@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qasdev00@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox