mm: hugetlb -- get rid of redundant if operation
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/3 early_printk - use sizeof instead of hardcoded number
Impact: cleanup
--- arch/x86/kernel/early_printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/early_printk.c +1 -1
@@ -886,7 +886,7 @@ asmlinkage void early_printk(const charva_list ap;va_start (ap, fmt); - n =vscnprintf (buf,512 , fmt, ap); + n =vscnprintf (buf,sizeof (buf), fmt, ap); early_console->write (early_console, buf, n);va_end (ap); }
PATCH 2/3 mm: hugetlb -- get rid of redundant if operation
In reply to a message not in the archiveAt this point we already know that 'addr' is not NULL so get rid of redundant 'if'. Probably gcc eliminate it by optimization pass.
--- mm/hugetlb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/hugetlb.c +1 -2
@@ -991,8 +991,7 @@ __attribute__((weak)) int alloc_bootmem_* puts them into the mem_map). */ m = addr; -if (m) - goto found; + goto found; }hstate_next_node (h); nr_nodes--;
Andrew Cc:-ed.
patch looks correct to me.
Ingo
Quoted 26 lines · Cyrill Gorcunov
At this point we already know that 'addr' is not NULL so get rid of redundant 'if'. Probably gcc eliminate it by optimization pass.
Signed-off-by Cyrill Gorcunov <[email protected]>CC William Irwin <[email protected]>--- mm/hugetlb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Index:
linux-2.6.git/mm/hugetlb.c
===================================================================mm/hugetlb.c +1
-2@@ -991,8 +991,7 @@ __attribute__((weak)) int alloc_bootmem_* puts them into the mem_map). */ m = addr; -if (m) - goto found; + goto found; }hstate_next_node (h); nr_nodes--;Signature · 1 line
--
PATCH 3/3 acpi: check for pxm_to_node_map overflow
In reply to a message not in the archiveIt is hardly (if ever) possible but in case of broken _PXM entry we could reach out of pxm_to_node_map array bounds in acpi_map_pxm_to_node() call. Lets check it (it's not that expensive and safe).
--- drivers/acpi/numa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/numa.c +1 -1
@@ -278,7 +278,7 @@ int acpi_get_node(acpi_handle *handle)int pxm, node =-1 ; pxm =acpi_get_pxm (handle); -if (pxm >=0 ) +if (pxm >=0 && pxm <MAX_PXM_DOMAINS ) node =acpi_map_pxm_to_node (pxm);return node;
Re: [patch 3/3] acpi: check for pxm_to_node_map overflow
Quoted 10 lines · Cyrill Gorcunov
It is hardly (if ever) possible but in case of broken
_PXMentry we could reach out ofpxm_to_node_maparray bounds inacpi_map_pxm_to_node()call. Lets check it (it's not that expensive and safe).Signed-off-by Cyrill Gorcunov <[email protected]>CC Len Brown <[email protected]>--- drivers/acpi/numa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
just curious - how did you find this - code review or some tool help like Sparse output or a compiler warning?
Ingo
Re: [patch 3/3] acpi: check for pxm_to_node_map overflow
[Ingo Molnar - Fri, Jan 02, 2009 at 10:23:30AM +0100]
| | * Cyrill Gorcunov <[email protected]> wrote: | | > It is hardly (if ever) possible but in case of broken _PXM | > entry we could reach out of pxm_to_node_map array | > bounds in acpi_map_pxm_to_node() call. Lets check it | > (it's not that expensive and safe). | > | > Signed-off-by: Cyrill Gorcunov <[email protected]> | > CC: Len Brown <[email protected]> | > --- | > drivers/acpi/numa.c | 2 +- | > 1 file changed, 1 insertion(+), 1 deletion(-) | | just curious - how did you find this - code review or some tool help like | Sparse output or a compiler warning? | | Ingo |
Unfortunately -- by reading the code :( I would prefer if gcc or sparse complain about it but we have indirect referring which is that hard to trace by any tool I believe (until say some emulator but even if we have such kind of tool we would need to tell it that 'there we have boundries we shouldn't cross)'. But to be fair -- I didn't try sparse here maybe it does complain :)
- Cyrill -
Re: [patch 3/3] acpi: check for pxm_to_node_map overflow
In reply to Cyrill Gorcunov[Cyrill Gorcunov - Fri, Jan 02, 2009 at 11:27:20AM +0300]
| It is hardly (if ever) possible but in case of broken _PXM | entry we could reach out of pxm_to_node_map array | bounds in acpi_map_pxm_to_node() call. Lets check it | (it's not that expensive and safe). | | Signed-off-by: Cyrill Gorcunov <[email protected]> | CC: Len Brown <[email protected]>
...
Oops, I forgot to CC Andi, sorry.
- Cyrill -