From: Hao Dongdong <doubled@leap-io-kernel.com>
To: Linmao Li <lilinmao@kylinos.cn>,
James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org
Cc: hare@kernel.org, dlemoal@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] scsi: leapraid: balance host references for firmware log VMAs
Date: Fri, 14 Aug 2026 16:05:16 +0800 [thread overview]
Message-ID: <4572b73c-da7a-405b-973d-43f0549082d0@leap-io-kernel.com> (raw)
In-Reply-To: <20260814033845.2971706-2-lilinmao@kylinos.cn>
在 2026/8/14 11:38, Linmao Li 写道:
> leapraid_fw_mmap() keeps the Scsi_Host reference obtained while
> looking up the adapter for the lifetime of the initial VMA. The VMA
> close callback drops that reference.
>
> The open callback is also invoked when a VMA is duplicated or split,
> but it only increments mmap_refcnt. Since every corresponding close
> callback drops a host reference, cloning the mapping can release the
> host while another VMA still refers to the adapter.
>
> Take a host device reference for every VMA open and release the lookup
> reference once the initial mapping has acquired its own reference. Use
> get_device() because a VMA can be cloned after the host enters SHOST_DEL;
> an existing VMA still pins the host at that point and open cannot fail.
>
> Fixes: 5597088c9e79 ("scsi: leapraid: Add new SCSI driver")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> ---
> drivers/scsi/leapraid/leapraid_app.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/leapraid/leapraid_app.c b/drivers/scsi/leapraid/leapraid_app.c
> index 742f19c07fcbb..841027ce2501c 100644
> --- a/drivers/scsi/leapraid/leapraid_app.c
> +++ b/drivers/scsi/leapraid/leapraid_app.c
> @@ -697,6 +697,7 @@ static void leapraid_fw_mmap_open(struct vm_area_struct *vma)
> if (!adapter)
> return;
>
> + get_device(&adapter->shost->shost_gendev);
> atomic_inc(&adapter->fw_log_desc.mmap_refcnt);
> }
>
> @@ -767,7 +768,6 @@ static int leapraid_fw_mmap(struct file *filp, struct vm_area_struct *vma)
> vma->vm_private_data = adapter;
> vma->vm_ops = &leapraid_fw_mmap_vm_ops;
> leapraid_fw_mmap_open(vma);
> - adapter = NULL;
>
> rc = 0;
> out_put:
Thanks for the fix. This correctly fixes the issue.
Reviewed-by: Dongdong Hao <doubled@leap-io-kernel.com>
next prev parent reply other threads:[~2026-08-14 8:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 3:38 [PATCH v3 0/2] scsi: leapraid: fix firmware log mmap lifetime Linmao Li
2026-08-14 3:38 ` [PATCH v3 1/2] scsi: leapraid: balance host references for firmware log VMAs Linmao Li
2026-08-14 8:05 ` Hao Dongdong [this message]
2026-08-14 3:38 ` [PATCH v3 2/2] scsi: leapraid: serialize firmware log mmap with teardown Linmao Li
2026-08-14 8:08 ` Hao Dongdong
2026-08-24 1:56 ` [PATCH v3 0/2] scsi: leapraid: fix firmware log mmap lifetime Martin K. Petersen (Oracle)
2026-08-26 15:20 ` Martin K. Petersen (Oracle)
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=4572b73c-da7a-405b-973d-43f0549082d0@leap-io-kernel.com \
--to=doubled@leap-io-kernel.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=dlemoal@kernel.org \
--cc=hare@kernel.org \
--cc=lilinmao@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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
all inboxes | Powered by JetHome®