[PATCH v3] nvme-pci: fix CMB mapping when CMBSZ Size field is zero
Kanchan Joshi
joshi.k at samsung.com
Wed Sep 2 20:53:52 PDT 2026
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 at samsung.com>
More information about the Linux-nvme
mailing list