mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
hw/block/nvme: harden cmb access
Since the controller has only supported PRPs so far it has not been required to check the ending address (addr + len - 1) of the CMB access for validity since it has been guaranteed to be in range of the CMB. This changes when the controller adds support for SGLs (next patch), so add that check. Signed-off-by: Klaus Jensen <k.jensen@samsung.com> Reviewed-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
parent
92a10ec17f
commit
6e0ac3a03f
1 changed files with 6 additions and 1 deletions
|
@ -142,7 +142,12 @@ static inline void *nvme_addr_to_cmb(NvmeCtrl *n, hwaddr addr)
|
|||
|
||||
static int nvme_addr_read(NvmeCtrl *n, hwaddr addr, void *buf, int size)
|
||||
{
|
||||
if (n->bar.cmbsz && nvme_addr_is_cmb(n, addr)) {
|
||||
hwaddr hi = addr + size - 1;
|
||||
if (hi < addr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (n->bar.cmbsz && nvme_addr_is_cmb(n, addr) && nvme_addr_is_cmb(n, hi)) {
|
||||
memcpy(buf, nvme_addr_to_cmb(n, addr), size);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue