Category: Linux

[POWERPC] arch/powerpc/platforms/82xx: Add missing of_node_put

Author: Julia Lawall <julia@diku.dk> Of_get_parent and of_find_compatible_node do a of_node_get, and thus a corresponding of_code_put is needed in both the error case and the normal return case. The problem was found using the following semantic match. (http://www.emn.fr/x-info/coccinelle/) // @@ type T,T1,T2; identifier E; statement S; expression x1,x2,x3; int ret; @@ T E; … * E …

Continue reading

[POWERPC] arch/powerpc/sysdev: Add missing of_node_put

Author: Julia Lawall <julia@diku.dk> The functions of_find_compatible_node and of_find_node_by_type both call of_node_get on their result. So any error handling code thereafter should call of_node_put(np). This is taken care of in the case where there is a goto out, but not when there is a direct return. The function irq_alloc_host puts np into the returned structure, …

Continue reading

[POWERPC] arch/powerpc/platforms/pseries: Add missing of_node_put

Author: Julia Lawall <julia@diku.dk> Of_get_parent and of_find_compatible_node do an of_node_get, and thus a corresponding of_code_put is needed in the error case. The problem was found using the following semantic match. (http://www.emn.fr/x-info/coccinelle/) // @@ type T,T1,T2; identifier E; statement S; expression x1,x2,x3; int ret; @@ T E; … * E = \(of_get_parent\|of_find_compatible_node\)(…); if (E == NULL) …

Continue reading

arch/cris: add a missing iounmap

Author: Julia Lawall <julia@diku.dk> An extra error handling label is needed for the case where the ioremap has succeeded. The problem was detected using the following semantic match (http://www.emn.fr/x-info/coccinelle/) // @@ type T,T1,T2; identifier E; statement S; expression x1,x2; constant C; int ret; @@ T E; … * E = ioremap(…); if (E == NULL) …

Continue reading

drivers/pcmcia: add missing pci_dev_get

Author: Julia Lawall <julia@diku.dk> pci_get_slot does a pci_dev_get, so pci_dev_put needs to be called in an error case. An extract of the semantic match used to find the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ type find1.T,T1,T2; identifier find1.E; statement find1.S; expression x1,x2,x3; expression find1.test; int ret != 0; @@ T E; … ( * …

Continue reading

drivers/pcmcia: Add missing iounmap

Author: Julia Lawall <julia@diku.dk> of_iomap calls ioremap, and so should be matched with an iounmap. At the two error returns, the result of calling of_iomap is only stored in a local variable, so these error paths need to call iounmap. Furthermore, this function ultimately stores the result of of_iomap in an array that is local …

Continue reading

arch/x86/kernel/io_apic_{64,32}.c: use time_before

Author: Julia Lawall <julia@diku.dk> The functions time_before, time_before_eq, time_after, and time_after_eq are more robust for comparing jiffies against other values. A simplified version of the semantic patch making this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @ change_compare_np @ expression E; @@ ( – jiffies = E + time_after_eq(jiffies,E) | – jiffies < E + time_before(jiffies,E) …

Continue reading

arch/x86/kernel/apm_32.c: use time_before, time_before_eq,

Author: Julia Lawall <julia@diku.dk> The functions time_before, time_before_eq, time_after, and time_after_eq are more robust for comparing jiffies against other values. A simplified version of the semantic patch making this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @ change_compare_np @ expression E; @@ ( – jiffies = E + time_after_eq(jiffies,E) | – jiffies < E + time_before(jiffies,E) …

Continue reading

arch/x86/ia32: use time_before, time_before_eq, etc.

Author: Julia Lawall <julia@diku.dk> The functions time_before, time_before_eq, time_after, and time_after_eq are more robust for comparing jiffies against other values. A simplified version of the semantic patch making this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @ change_compare_np @ expression E; @@ ( – jiffies = E + time_after_eq(jiffies,E) | – jiffies < E + time_before(jiffies,E) …

Continue reading

V4L/DVB (7035): drivers/media/common: Add missing video_device_release

Author: Julia Lawall <julia@diku.dk> Video_device_alloc returns the result of a kzalloc. In this case, the value is stored in a local variable which is not copied elsewhere before the point of the error return (video_register_device does not save its first argument anywhere if it returns a negative value). Thus, a video_device_release it needed before the …

Continue reading