Re: [PATCH] hw/nvme: fix unintentional integer overflow in shift

Klaus Jensen <[email protected]>
Newsgroups gmane.comp.emulators.qemu.block,gmane.comp.emulators.qemu,gmane.comp.emulators.qemu.stable
Message-ID <[email protected]>
On Jul 28 11:34, Philippe Mathieu-Daudé wrote:
> On 28/7/26 11:26, Klaus Jensen wrote:
> > From: Klaus Jensen <[email protected]>
> > 
> > Fix potentially overflowing shift operation.
> > 
> > Cc: [email protected]
> > Suggested-by: Peter Maydell <[email protected]>
> > Resolves: Coverity CID 1663674
> > Fixes: ec917cd49918 ("hw/nvme: fix FDP set FDP events")
> > Signed-off-by: Klaus Jensen <[email protected]>
> > ---
> >   hw/nvme/ctrl.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> > index a67e1598891c..40f22fdc40bd 100644
> > --- a/hw/nvme/ctrl.c
> > +++ b/hw/nvme/ctrl.c
> > @@ -6622,7 +6622,7 @@ static uint16_t nvme_set_feature_fdp_events(NvmeCtrl *n, NvmeNamespace *ns,
> >           if (!shift && event_type) {
> >               continue;
> >           }
> > -        event_mask |= (1 << nvme_fdp_evf_shifts[events[i]]);
> > +        event_mask |= (1ULL << nvme_fdp_evf_shifts[events[i]]);
> 
> Alternatively:
> 
>   event_mask = deposit64(event_mask, nvme_fdp_evf_shifts[events[i]], 1);
> 

Better! Thanks!

> >       }
> >       if (enable) {
> > 
> > ---
> > base-commit: 299e7557ed15a9a325620698add379a3ce2d1d95
> > change-id: 20260728-fix-shift-525e53c1df6f
> > 
> > Best regards,
> 
>
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAABCgAdFiEEUigzqnXi3OaiR2bATeGvMW1PDekFAmpoeZYACgkQTeGvMW1P
Demspwf+MMVXN6dlQS+1AgqbhwYAEU0Hu0cSXASc5yW+dfBspITu5pni+ZlhiohT
+vSmh2yCHtCnMn2+F7K/GDqOsT3oFtrsMWXhzJCfrd8R3RBtVRHds8lIeAJ2Ml97
pEPbuD7w2Ea8o93Yk1WTcexaZ3sUVQeDaT2nejz+VJemtEjkEiMQmMfNS8zMv2Rn
mVCcwnqb1f2kTWRNDPexguzE5D6EGWUaiVpxG6vUJumNoUVD03Es/cOh8rlr98qS
4PqfHHVdWBwuH3MD76lOvreByAlmxjW8F0T9HVc5r20QBJLeFaCpattFRJF694PE
2lzbASIqAk5u8escXHA+h1tE6TG5Og==
=elDZ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.