On Wed, 2023-01-04 at 14:57 +1100, Russell Currey wrote:
> > +       maxobjlabelsize = be16_to_cpu(config->maxobjlabelsize) -
> > +                         MAX_LABEL_ATTR_SIZE;
> > +       maxobjlabelsize = maxobjlabelsize < 0 ? 0 :
> > maxobjlabelsize;
> 
> Isn't a bit of precision lost here?  There has to be a better way to
> handle this.  We get a be16 from the hypervisor, turn it into a u16,
> and assign that to an s16 in order to handle underflow.  Can we just
> check if the size we're given is large enough?  The hypervisor
> documentation also says this value must be at least 255, if we sanity
> check that we don't have to worry about underflow.

Agreed, and it makes more sense for the value that we return to the
user to be the same as the number we actually get from the hypervisor.
I'll fix it in the next spin.

-- 
Andrew Donnellan    OzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited

Reply via email to