|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH for-4.13 v3] xen/arm: fix buf size in make_cpus_node
Hi Stefano, On 09/10/2019 00:12, Stefano Stabellini wrote: I am not entirely happy with the commit message. There are no real issue with the current code (the buffer is big enough) as mpdir_aff can only have [23:0] set in the current code. The patch is only hardening the code and that should be reflected in the commit message. So how about: xen/arm: domain_build: Harden make_cpus_node() make_cpus_node() is using a static buffer to generate the FDT node name.While mpdir_aff is a 64-bit integer, we only ever use the bits [23:0] as only AFF{0, 1, 2} are supported for now. To avoid any potential issue in the future, check that mpdir_aff has only bits [23:0] set. At the same time, take the opportunity to reduce the size of the buffer. Indeed, only 8 characters is useful to generate an 32-bit hexadecimal number. So sizeof("cpu@") + 8 = 13 characters is sufficient here. I think you want to update the comment to say "32-bit hexa number". - char buf[15]; + char buf[13]; This is a confusing code to read because above you mention this is a 32-bit number, but below you are using PRIx64. It takes a bit of time to figure out that mpdir_aff will always have bits above 32-bit zeroed. I would prefer to use a temporary variable for the register, but I would be happy to consider a suitable comment in code. Cheers, -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |