From: "Peter Wang (王信友)" <peter.wang@mediatek.com>
To: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
"avri.altman@sandisk.com" <avri.altman@sandisk.com>,
"bvanassche@acm.org" <bvanassche@acm.org>,
"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Cc: "Alice Chao (趙珮均)" <Alice.Chao@mediatek.com>,
"Eddie Huang (黃智傑)" <eddie.huang@mediatek.com>,
"CC Chou (周志杰)" <cc.chou@mediatek.com>,
"Ed Tsai (蔡宗軒)" <Ed.Tsai@mediatek.com>,
wsd_upstream <wsd_upstream@mediatek.com>,
"Chaotian Jing (井朝天)" <Chaotian.Jing@mediatek.com>,
"Chun-Hung Wu (巫駿宏)" <Chun-hung.Wu@mediatek.com>,
"Naomi Chu (朱詠田)" <Naomi.Chu@mediatek.com>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"Tun-yu Yu (游敦聿)" <Tun-yu.Yu@mediatek.com>
Subject: Re: [PATCH v1] ufs: core: Fix possible NULL pointer dereference in ufshcd_add_command_trace()
Date: Tue, 24 Feb 2026 05:29:34 +0000 [thread overview]
Message-ID: <399765bade9b7adcca89a94313e71635d1336172.camel@mediatek.com> (raw)
In-Reply-To: <5017b907-16de-4d7f-a7c6-dbc504ffd1eb@acm.org>
On Mon, 2026-02-23 at 09:13 -0800, Bart Van Assche wrote:
> This will cause "-1" to be assigned to hwq_id instead of a queue
> number
> if a request has already been completed. Wouldn't it be better to
> introduce a new helper function that returns READ_ONCE(req->mq_hctx)
> ->queue_num instead of making the above change?
>
> Thanks,
>
> Bart.
Hi Bart,
The default value of hwq_id is 0:
u32 hwq_id = 0;
Additionally, since READ_ONCE(req->mq_hctx) could be NULL,
ufshcd_mcq_req_to_hwq already takes this into account, as shown below:
struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba,
struct request *req)
{
struct blk_mq_hw_ctx *hctx = READ_ONCE(req->mq_hctx);
return hctx ? &hba->uhq[hctx->queue_num] : NULL;
}
Therefore, there is no need to assign hwq_id separately.
Thanks
Peter
next prev parent reply other threads:[~2026-02-24 5:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 6:56 [PATCH v1] ufs: core: Fix possible NULL pointer dereference in ufshcd_add_command_trace() peter.wang
2026-02-23 17:13 ` Bart Van Assche
2026-02-24 5:29 ` Peter Wang (王信友) [this message]
2026-02-24 16:48 ` Bart Van Assche
2026-02-25 5:53 ` Peter Wang (王信友)
2026-02-24 16:50 ` Bart Van Assche
2026-02-25 2:08 ` Martin K. Petersen
2026-02-25 19:45 ` Bart Van Assche
2026-02-28 22:37 ` Martin K. Petersen
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=399765bade9b7adcca89a94313e71635d1336172.camel@mediatek.com \
--to=peter.wang@mediatek.com \
--cc=Alice.Chao@mediatek.com \
--cc=Chaotian.Jing@mediatek.com \
--cc=Chun-hung.Wu@mediatek.com \
--cc=Ed.Tsai@mediatek.com \
--cc=Naomi.Chu@mediatek.com \
--cc=Tun-yu.Yu@mediatek.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@sandisk.com \
--cc=bvanassche@acm.org \
--cc=cc.chou@mediatek.com \
--cc=eddie.huang@mediatek.com \
--cc=jejb@linux.ibm.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=wsd_upstream@mediatek.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