Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Kanchan Joshi <joshi.k@samsung.com>
To: kangfenglong <kangfenglong@huawei.com>, kbusch@kernel.org
Cc: linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org,
	liuyonglong@huawei.com, seven.wangyu@huawei.com
Subject: Re: [PATCH v3] nvme-pci: fix CMB mapping when CMBSZ Size field is zero
Date: Thu, 3 Sep 2026 09:23:52 +0530	[thread overview]
Message-ID: <bc7c089c-9357-448f-b6d4-fbc72b7e3c6c@samsung.com> (raw)
In-Reply-To: <20260622024129.40800-1-kangfenglong@huawei.com>

On 6/22/2026 8:11 AM, kangfenglong wrote:
>   static void nvme_map_cmb(struct nvme_dev *dev)
>   {
> -	u64 size, offset;
> +	u64 size, unit_size, offset;
>   	resource_size_t bar_size;
>   	struct pci_dev *pdev = to_pci_dev(dev->dev);
>   	int bar;
> @@ -2472,9 +2475,15 @@ static void nvme_map_cmb(struct nvme_dev *dev)
>   	dev->cmbsz = readl(dev->bar + NVME_REG_CMBSZ);
>   	if (!dev->cmbsz)
>   		return;
> +	if (!nvme_cmb_size(dev))
> +		return;
>   	dev->cmbloc = readl(dev->bar + NVME_REG_CMBLOC);
>   
> -	size = nvme_cmb_size_unit(dev) * nvme_cmb_size(dev);
> +	unit_size = nvme_cmb_size_unit(dev);
> +	if (!unit_size)
> +		return;
> +	if (check_mul_overflow(unit_size, nvme_cmb_size(dev), &size))
> +		return;
>   	offset = nvme_cmb_size_unit(dev) * NVME_CMB_OFST(dev->cmbloc);

nit: now unit_size can be used in this line.

With that, LGTM.

Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>



      parent reply	other threads:[~2026-09-03  3:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260622031353epcas5p20f6585c6c8c9b2753e6884d99fe6670a@epcas5p2.samsung.com>
2026-06-22  2:41 ` [PATCH v3] nvme-pci: fix CMB mapping when CMBSZ Size field is zero kangfenglong
2026-06-22  2:47   ` sashiko-bot
2026-09-02  7:45   ` Kangfenglong
2026-09-03  3:53   ` Kanchan Joshi [this message]

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=bc7c089c-9357-448f-b6d4-fbc72b7e3c6c@samsung.com \
    --to=joshi.k@samsung.com \
    --cc=kangfenglong@huawei.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=seven.wangyu@huawei.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