diff mbox series

spapr: nested: use bitwise NOT operator for flags check

Message ID 20240329043436.2857533-1-harshpb@linux.ibm.com
State New
Headers show
Series spapr: nested: use bitwise NOT operator for flags check | expand

Commit Message

Harsh Prateek Bora March 29, 2024, 4:34 a.m. UTC
Check for flag bit in H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE need to use
bitwise NOT operator to ensure no other flag bits are set.
Reported by Coverity as CID 1540008, 1540009.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off by: Harsh Prateek Bora <harshpb@linux.ibm.com>
---
 hw/ppc/spapr_nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé March 29, 2024, 12:38 p.m. UTC | #1
On 29/3/24 05:34, Harsh Prateek Bora wrote:
> Check for flag bit in H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE need to use
> bitwise NOT operator to ensure no other flag bits are set.
> Reported by Coverity as CID 1540008, 1540009.
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off by: Harsh Prateek Bora <harshpb@linux.ibm.com>
> ---
>   hw/ppc/spapr_nested.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/hw/ppc/spapr_nested.c b/hw/ppc/spapr_nested.c
index 936659b4c0..c02785756c 100644
--- a/hw/ppc/spapr_nested.c
+++ b/hw/ppc/spapr_nested.c
@@ -1511,7 +1511,7 @@  static target_ulong h_guest_getset_state(PowerPCCPU *cpu,
     if (flags & H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE) {
         gsr.flags |= GUEST_STATE_REQUEST_GUEST_WIDE;
     }
-    if (flags & !H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE) {
+    if (flags & ~H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE) {
         return H_PARAMETER; /* flag not supported yet */
     }