qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH] PCI: add param check for api


From: Cao jin
Subject: Re: [Qemu-trivial] [PATCH] PCI: add param check for api
Date: Tue, 12 Jan 2016 14:39:31 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0



On 01/11/2016 04:32 PM, Michael Tokarev wrote:
21.11.2015 10:45, Cao jin wrote:
add param check for pci_add_capability2, as it is a public API.

Signed-off-by: Cao jin <address@hidden>
---
  hw/pci/pci.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 168b9cc..6938f64 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2144,6 +2144,9 @@ int pci_add_capability2(PCIDevice *pdev, uint8_t cap_id,
      uint8_t *config;
      int i, overlapping_cap;

+    assert(size > 0);
+    assert(offset >= PCI_CONFIG_HEADER_SIZE || !offset);
+

I'd like to see some ACKs/Reviews for this one, in particular why
size should be != 0.

see pci_find_space(), if size == 0, I guess it will always return 0.
But I should admit that I did made a mistake, I will talk about it in
next mail.

Also either move offset assert to the below
"else" clause or rewrite it to be offset == 0 instead if !offset :)

Thanks,

/mjt

      if (!offset) {
          offset = pci_find_space(pdev, size);
          if (!offset) {




.


--
Yours Sincerely,

Cao jin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]