pci: Sanity check mask argument to pci_set_*_by_mask()
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 18 Aug 2022 13:54:21 +0000 (14:54 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 9 Oct 2022 20:38:45 +0000 (16:38 -0400)
commit775cc426a986742fb252dd3aa865763c10cdb438
treea1514d809e56b3eecbe97fe242d5905f10760df4
parent31e039e76d60fab708d49444ba40effc3037670d
pci: Sanity check mask argument to pci_set_*_by_mask()

Coverity complains that in functions like pci_set_word_by_mask()
we might end up shifting by more than 31 bits. This is true,
but only if the caller passes in a zero mask. Help Coverity out
by asserting that the mask argument is valid.

Fixes: CID 1487168
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20220818135421.2515257-3-peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
include/hw/pci/pci.h