[PATCH] [video/sis/sis_main.c] add parentheses
'!' has a higher priority than '': bitanding has no effect. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c index 93ae747..5b28fa2 100644 --- a/drivers/video/sis/sis_main.c +++ b/drivers/video/sis/sis_main.c @@ -427,7 +427,7 @@ sisfb_interpret_edid(struct sisfb_monitor *monitor, u8 *buffer) monitor-feature = buffer[0x18]; - if(!buffer[0x14] 0x80) { + if(!(buffer[0x14] 0x80)) { if(!(buffer[0x14] 0x08)) { printk(KERN_INFO sisfb: WARNING: Monitor does not support separate syncs\n); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] [drivers/misc/asus-laptop.c] add parentheses
'!' has a higher priority than '': bitanding has no effect. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index 7dce318..65c67d1 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c @@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, int mask) switch (mask) { case MLED_ON: - out = !out 0x1; + out = !(out 0x1); break; case GLED_ON: out = (out 0x1) + 1; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] [rivers/media/video/tvaudio.c] add parentheses
'!' has a higher priority than '': bitanding has no effect. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index a755605..01ebcec 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -1571,14 +1571,14 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip, ctrl-value=chip-muted; return 0; case V4L2_CID_AUDIO_VOLUME: - if (!desc-flags CHIP_HAS_VOLUME) + if (!(desc-flags CHIP_HAS_VOLUME)) break; ctrl-value = max(chip-left,chip-right); return 0; case V4L2_CID_AUDIO_BALANCE: { int volume; - if (!desc-flags CHIP_HAS_VOLUME) + if (!(desc-flags CHIP_HAS_VOLUME)) break; volume = max(chip-left,chip-right); if (volume) @@ -1621,7 +1621,7 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip, { int volume,balance; - if (!desc-flags CHIP_HAS_VOLUME) + if (!(desc-flags CHIP_HAS_VOLUME)) break; volume = max(chip-left,chip-right); @@ -1642,7 +1642,7 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip, case V4L2_CID_AUDIO_BALANCE: { int volume, balance; - if (!desc-flags CHIP_HAS_VOLUME) + if (!(desc-flags CHIP_HAS_VOLUME)) break; volume = max(chip-left,chip-right); @@ -1702,7 +1702,7 @@ static int chip_command(struct i2c_client *client, break; case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_BALANCE: - if (!desc-flags CHIP_HAS_VOLUME) + if (!(desc-flags CHIP_HAS_VOLUME)) return -EINVAL; break; case V4L2_CID_AUDIO_BASS: -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [2.6 patch] atm/idt77105.c: fix section mismatch
Adrian Bunk wrote: EXPORT_SYMBOL'ed code mustn't be __*init. Is it correct that the cases below are section mismatches as well? If required I'll send separate patches to the respective maintainers lists. __init arch/arm/mach-imx/generic.c:330:EXPORT_SYMBOL(set_imx_fb_info); __devinit arch/parisc/kernel/pci.c:245:EXPORT_SYMBOL(pcibios_resource_to_bus); arch/powerpc/kernel/pci_64.c:371:EXPORT_SYMBOL(of_scan_bus); arch/powerpc/kernel/pci_64.c:460:EXPORT_SYMBOL(of_scan_pci_bridge); arch/powerpc/kernel/pci_64.c:842:EXPORT_SYMBOL(pcibios_fixup_device_resources); arch/powerpc/kernel/pci_64.c:862:EXPORT_SYMBOL(pcibios_setup_new_device); arch/powerpc/kernel/pci_64.c:908:EXPORT_SYMBOL(pcibios_fixup_bus); arch/ia64/pci/pci.c:477:EXPORT_SYMBOL_GPL(pcibios_fixup_device_resources); arch/powerpc/kernel/vio.c:240:EXPORT_SYMBOL(vio_register_device_node); arch/powerpc/kernel/vio.c:309:EXPORT_SYMBOL(vio_unregister_device); __cpu_init arch/x86/kernel/topology.c:60:EXPORT_SYMBOL(arch_register_cpu); -- EXPORT_SYMBOL'ed code mustn't be __*init. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c index 4cfc9d3..92e098a 100644 --- a/arch/arm/mach-imx/generic.c +++ b/arch/arm/mach-imx/generic.c @@ -323,7 +323,7 @@ void __init imx_set_mmc_info(struct imxmmc_platform_data *info) static struct imxfb_mach_info imx_fb_info; -void __init set_imx_fb_info(struct imxfb_mach_info *hard_imx_fb_info) +void set_imx_fb_info(struct imxfb_mach_info *hard_imx_fb_info) { memcpy(imx_fb_info,hard_imx_fb_info,sizeof(struct imxfb_mach_info)); } diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 488e48a..8c200a8 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -470,7 +470,7 @@ pcibios_fixup_resources(struct pci_dev *dev, int start, int limit) } } -void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) +void pcibios_fixup_device_resources(struct pci_dev *dev) { pcibios_fixup_resources(dev, 0, PCI_BRIDGE_RESOURCES); } diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c index 507d0ac..9cf3cfc 100644 --- a/arch/parisc/kernel/pci.c +++ b/arch/parisc/kernel/pci.c @@ -195,7 +195,7 @@ void __init pcibios_init_bus(struct pci_bus *bus) } /* called by drivers/pci/setup-bus.c:pci_setup_bridge(). */ -void __devinit pcibios_resource_to_bus(struct pci_dev *dev, +void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, struct resource *res) { #ifdef CONFIG_64BIT diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 9f63bdc..5f1151a 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -338,7 +338,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, } EXPORT_SYMBOL(of_create_pci_dev); -void __devinit of_scan_bus(struct device_node *node, +void of_scan_bus(struct device_node *node, struct pci_bus *bus) { struct device_node *child = NULL; @@ -370,7 +370,7 @@ void __devinit of_scan_bus(struct device_node *node, } EXPORT_SYMBOL(of_scan_bus); -void __devinit of_scan_pci_bridge(struct device_node *node, +void of_scan_pci_bridge(struct device_node *node, struct pci_dev *dev) { struct pci_bus *bus; @@ -818,7 +818,7 @@ static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev) } } -void __devinit pcibios_fixup_device_resources(struct pci_dev *dev, +void pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus) { /* Update device resources. */ @@ -841,7 +841,7 @@ void __devinit pcibios_fixup_device_resources(struct pci_dev *dev, } EXPORT_SYMBOL(pcibios_fixup_device_resources); -void __devinit pcibios_setup_new_device(struct pci_dev *dev) +void pcibios_setup_new_device(struct pci_dev *dev) { struct dev_archdata *sd = dev-dev.archdata; @@ -879,7 +879,7 @@ static void __devinit do_bus_setup(struct pci_bus *bus) } } -void __devinit pcibios_fixup_bus(struct pci_bus *bus) +void pcibios_fixup_bus(struct pci_bus *bus) { struct pci_dev *dev = bus-self; struct device_node *np; diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c index 19a5656..70a2ce4 100644 --- a/arch/powerpc/kernel/vio.c +++ b/arch/powerpc/kernel/vio.c @@ -178,7 +178,7 @@ static void __devinit vio_dev_release(struct device *dev) * Returns a pointer to the created vio_dev or NULL if node has * NULL device_type or compatible fields. */ -struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node) +struct vio_dev * vio_register_device_node(struct device_node *of_node) { struct vio_dev *viodev; const unsigned int *unit_address; @@ -302,7 +302,7 @@ static struct device_attribute vio_dev_attrs[] = { __ATTR_NULL }; -void __devinit vio_unregister_device
[PATCH][ppc] logical/bitand typo in powerpc/boot/4xx.c
logical/bitand typo Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/arch/powerpc/boot/4xx.c b/arch/powerpc/boot/4xx.c index ebf9e21..dcfb459 100644 --- a/arch/powerpc/boot/4xx.c +++ b/arch/powerpc/boot/4xx.c @@ -104,7 +104,7 @@ void ibm4xx_denali_fixup_memsize(void) val = DDR_GET_VAL(val, DDR_CS_MAP, DDR_CS_MAP_SHIFT); cs = 0; while (val) { - if (val 0x1) + if (val 0x1) cs++; val = val 1; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH][ppc] logical/bitand typo in powerpc/boot/4xx.c
Joe Perches wrote: On Wed, 2008-01-23 at 23:37 +0100, Roel Kluin wrote: Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/arch/powerpc/boot/4xx.c b/arch/powerpc/boot/4xx.c index ebf9e21..dcfb459 100644 --- a/arch/powerpc/boot/4xx.c +++ b/arch/powerpc/boot/4xx.c @@ -104,7 +104,7 @@ void ibm4xx_denali_fixup_memsize(void) val = DDR_GET_VAL(val, DDR_CS_MAP, DDR_CS_MAP_SHIFT); cs = 0; while (val) { -if (val 0x1) +if (val 0x1) cs++; val = val 1; I think this pattern should be added to checkpatch I agree but... Signed-off-by: Joe Perches [EMAIL PROTECTED] diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 579f50f..147e573 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1337,6 +1337,11 @@ sub process { } } +# Check for bitwise tests written as boolean + if ($line =~ /\\\s*0[xX]/) { + WARN(boolean test with hexadecimal, perhaps just 1 \?\n . $herecurr); + } + when you use git-grep -n \(\|||\)${s}0x\([A-Z0-9]*\|[a-z0-9]*\), (with s=[[:space:]]*) there will be false positives like if (relocation -0x2 || 0x1fffc relocation) if (ARCH_SUN4C_SUN4 addr 0xe000 0x2000 - len addr) { (and more) However, if you search with git-grep -n \(\|||\)${s}0x\([A-Z0-9]*\|[a-z0-9]*\)$s\()\|\|||\) you won't get these false positives, but you do get the one I fixed. Also there is the same logic flipped (though it did not give matches at this time): git-grep -n \(\|||\|(\)${s}0x\([A-Z0-9]*\|[a-z0-9]*\)$s\(\|||\) so i'd propose to change that to -- Catch boolean tests with hexadecimals, based on suggestion by Joe Perches Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 579f50f..8ac7c7b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1337,6 +1337,12 @@ sub process { } } +# Check for bitwise tests written as boolean + if ($line =~ /(?:(?:\(|\\|\|\|)\s*0[xX]\s*(?:|\|\|)| + (?:\\|\|\|)\s*0[xX]\s*(?:\)||\|\|))/) { + WARN(boolean test with hexadecimal, perhaps just 1 \ or \|?\n . $herecurr); + } + # if and else should not have general statements after it if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/ $1 !~ /^\s*(?:\sif|{|\\|$)/) { -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Announce: Linux-next (Or Andrew's dream :-))
Linus Torvalds wrote: On Wed, 13 Feb 2008, Roel Kluin wrote: In nature there is a lot of duplication: several copies of genes can exist and different copies may have a distinct evolution. This is true of very complex animals, but much less so when looking at things like bacteria (and arguably, any current sw project is closer to bacteria in complexity than anything mammalian). In bacteria (and viruses), duplication of DNA/RNA is a big cost of living in general, and as a result there is *much* less junk DNA. So in an evolutionary sense, it's much closer to what the kernel should have (with occasional duplication of code and interfaces to allow new functionality, but rather aggressive pruning of the excess baggage). I like the comparison, and while I wrote my comment I have to admit I was also thinking of bacteria and virusses as an exception: There the speed of replication can be an important factor for survival. Less DNA means faster replication and therefore the pressure is on removal of junk DNA. It can be disputed however that removal of 'junk sourcecode' is a survival factor for the linux kernel but the benefit may be disputable as well. In other words, all of these choices are a matter of balance. In some areas, excess code is not a sufficient downside, and we keep even broken source code around with no actual function, just because (or rather, because the cost of carrying it around is so small that nobody cares). That's true in the kernel as in biology: check out not just deprecated code, but the drivers and other odds-and-ends that are explicitly marked as non-coding DNA (we just happen to call them BROKEN in our Kconfig). Linus Maybe we can elaborate a bit on this comparison, just for fun: I think not the linux kernel alone, but rather the entire Linux OS could be compared with a cell. The kernel source encodes vital software parts including the interactions with hardware - the environment for the computer. Gcc can be compared with the (transcription and) translation machinery. DNA can be seen as a language that encodes proteins, with biological functions: Some are vital, including ones that allow interactions with the environment: The cellular environment is beyond the membrane. Interactions occur through membrane receptors, channels, etc. Interaction between proteins can be compared with functions selectively calling other functions. Activation of certain proteins can cause a cascade of protein interactions, comparable with function calls in a loop: the activated protein activates particular protein(s) several times. Some proteins influence intracellular messengers: cellular global variables. Transmembrane receptors responding to extracellular signals transmit this through conformational changes across the membrane to the intracellular region: These structural changes may allow interactions with new proteins. Maybe comparable with a combination of hardware interrupts, signals and the userspace? The response to extracellular signals often depends on several sequential interactions between proteins. This provides a protective layer that can be compared with the kernelspace layer. This is where the comparison probably becomes too biased to continue. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Announce: Linux-next (Or Andrew's dream :-))
Alan Cox wrote: Evolution in nature and changes in code are different because in code junk and bugs are constantly removed. In biology junk is allowed and may provide a pool for future development. Linux development is intended and not survival. I would be interested to see any evidence (rather than intuition) to support that, given that both appear to be the same kind of structure and that structure is nowadays fairly well understood. What do you mean with structure, the evolution? that both are a language? -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: + bluetooth-fix-warning-in-net-bluetooth-hci_sysfsc.patch added to -mm tree
Andrew Morton wrote: On Sat, 16 Feb 2008 01:27:41 -0800 (PST) David Miller [EMAIL PROTECTED] wrote: From: [EMAIL PROTECTED] Date: Fri, 15 Feb 2008 20:49:33 -0800 Subject: bluetooth: fix warning in net/bluetooth/hci_sysfs.c From: Andrew Morton [EMAIL PROTECTED] net/bluetooth/hci_sysfs.c: In function 'del_conn': net/bluetooth/hci_sysfs.c:339: warning: suggest parentheses around assignment used as truth value Cc: Dave Young [EMAIL PROTECTED] Cc: David S. Miller [EMAIL PROTECTED] Signed-off-by: Andrew Morton [EMAIL PROTECTED] Linus barfed when this exact patch got posted a few weeks ago, he said he considers just adding parenthesis to quiet this warning awful and explicit NULL test should be used. - while (dev = device_find_child(conn-dev, NULL, __match_tty)) { + while ((dev = device_find_child(conn-dev, NULL, __match_tty))) { hrm. box:/usr/src/linux-2.6.25-rc2 grep -r 'while [(][(].*{$' . | wc -l 1240 box:/usr/src/linux-2.6.25-rc2 grep -r 'while [(][(].*{$' . | grep -v NULL | wc -l 867 so two thirds of them presently don't bother testing for NULL. It's a pretty common idiom. (adds the != NULL, sees that it reaches column 82, drops patch in disgust) Not my results: # greps for 'while ((x = y(...)))' see below for variables git-grep -n -A2 while | sed -n s/^\([^\.]*\.[chsS]-[0-9]*-\|\([^\.]*\.[chsS]:[0-9]*:\)$s\)\(.*\)$/\2\3/p | tr \n @ | grep -o @[EMAIL PROTECTED]($z($z$W$z=$z$W$z($h)$z)$z) | tr @\t | tr -s | wc -l 262 # while ((x = y(...)) != NULL) git-grep -n -A2 while | sed -n s/^\([^\.]*\.[chsS]-[0-9]*-\|\([^\.]*\.[chsS]:[0-9]*:\)$s\)\(.*\)$/\2\3/p | tr \n @ | grep -o @[EMAIL PROTECTED]($z($z$W$z=$z$W$z($h)$z)$z\!=${z}NULL$z) | tr @\t | tr -s | wc -l 333 # while ((x = y(...)) != 0) git-grep -n -A2 while | sed -n s/^\([^\.]*\.[chsS]-[0-9]*-\|\([^\.]*\.[chsS]:[0-9]*:\)$s\)\(.*\)$/\2\3/p | tr \n @ | grep -o @[EMAIL PROTECTED]($z($z$W$z=$z$W$z($h)$z)$z\!=${z}0$z) | tr @\t | tr -s | wc -l 45 # while (!(x = y(...))) git-grep -n -A2 while | sed -n s/^\([^\.]*\.[chsS]-[0-9]*-\|\([^\.]*\.[chsS]:[0-9]*:\)$s\)\(.*\)$/\2\3/p | tr \n @ | grep -o @[EMAIL PROTECTED]($z\!$z($z$W$z=$z$W$z($h)$z)$z) | tr @\t | tr -s | wc -l 19 V=[A-Za-z_]\+[A-Za-z0-9_]* W=$V\(\[$V\]\|\[[0-9]\+\]\|\.$V\|-$V\)* s=[[:space:]]* h=[^()]*\(([^()]*)[^()]*\)* z=[EMAIL PROTECTED]:space:]]* -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] [x86] arch/x86/kernel/signal_32.c: replace !likely(x) by likely(!x)
Replace !likely(x) by likely(!x) Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c index caee1f0..335872f 100644 --- a/arch/x86/kernel/signal_32.c +++ b/arch/x86/kernel/signal_32.c @@ -303,7 +303,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size) * If we are on the alternate signal stack and would overflow it, don't. * Return an always-bogus address instead so we will die with SIGSEGV. */ - if (on_sig_stack(sp) !likely(on_sig_stack(sp - frame_size))) + if (on_sig_stack(sp) likely(!on_sig_stack(sp - frame_size))) return (void __user *) -1L; /* This is the X/Open sanctioned signal stack switching. */ -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] kernel/{exit.c, signal.c, power/process.c}: replace !likely(x) by likely(!x)
Not entirely sure who to send this to --- Replace !likely(x) by likely(!x) Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/kernel/exit.c b/kernel/exit.c index 506a957..df207fc 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1497,7 +1497,7 @@ repeat: /* * We don't reap group leaders with subthreads. */ - if (!likely(options WEXITED)) + if (likely(!(options WEXITED))) continue; retval = wait_task_zombie(p, (options WNOWAIT), infop, @@ -1508,7 +1508,7 @@ repeat: * exit, stop, or stop and then continue. */ flag = 1; - if (!unlikely(options WCONTINUED)) + if (unlikely(!(options WCONTINUED))) continue; retval = wait_task_continued(p, (options WNOWAIT), infop, diff --git a/kernel/power/process.c b/kernel/power/process.c index 7c2118f..b42254b 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -36,7 +36,7 @@ static inline int freezeable(struct task_struct * p) */ static inline void frozen_process(void) { - if (!unlikely(current-flags PF_NOFREEZE)) { + if (unlikely(!(current-flags PF_NOFREEZE))) { current-flags |= PF_FROZEN; wmb(); } diff --git a/kernel/signal.c b/kernel/signal.c index 84917fe..1155e16 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1308,7 +1308,7 @@ int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p) */ rcu_read_lock(); - if (!likely(lock_task_sighand(p, flags))) { + if (likely(!lock_task_sighand(p, flags))) { ret = -1; goto out_err; } @@ -1548,7 +1548,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, int why) static inline int may_ptrace_stop(void) { - if (!likely(current-ptrace PT_PTRACED)) + if (likely(!(current-ptrace PT_PTRACED))) return 0; /* * Are we in the middle of do_coredump? @@ -1574,7 +1574,7 @@ static int sigkill_pending(struct task_struct *tsk) { return ((sigismember(tsk-pending.signal, SIGKILL) || sigismember(tsk-signal-shared_pending.signal, SIGKILL)) - !unlikely(sigismember(tsk-blocked, SIGKILL))); +unlikely(!sigismember(tsk-blocked, SIGKILL))); } /* @@ -1625,7 +1625,7 @@ static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info) spin_unlock_irq(current-sighand-siglock); try_to_freeze(); read_lock(tasklist_lock); - if (!unlikely(killed) may_ptrace_stop()) { + if (unlikely(!killed) may_ptrace_stop()) { do_notify_parent_cldstop(current, CLD_TRAPPED); read_unlock(tasklist_lock); schedule(); @@ -1717,7 +1717,7 @@ static int do_signal_stop(int signr) } else { struct task_struct *t; - if (!likely(sig-flags SIGNAL_STOP_DEQUEUED) || + if (likely(!(sig-flags SIGNAL_STOP_DEQUEUED)) || unlikely(sig-group_exit_task)) return 0; /* -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/3] Fix Unlikely(x) == y
The patch below was not yet tested. If it's correct as it is, please comment. --- Fix Unlikely(x) == y Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/arch/powerpc/platforms/ps3/interrupt.c b/arch/powerpc/platforms/ps3/interrupt.c index 3a6db04..a14e5cd 100644 --- a/arch/powerpc/platforms/ps3/interrupt.c +++ b/arch/powerpc/platforms/ps3/interrupt.c @@ -709,7 +709,7 @@ static unsigned int ps3_get_irq(void) asm volatile(cntlzd %0,%1 : =r (plug) : r (x)); plug = 0x3f; - if (unlikely(plug) == NO_IRQ) { + if (unlikely(plug == NO_IRQ)) { pr_debug(%s:%d: no plug found: thread_id %lu\n, __func__, __LINE__, pd-thread_id); dump_bmp(per_cpu(ps3_private, 0)); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/3] drivers/s390/block/dcssblk.c: Fix Unlikely(x) != y
The patch below was not yet tested. If it's correct as it is, please comment. --- Fix Unlikely(x) != y Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 3faf053..e6c94db 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -666,7 +666,7 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio) page_addr = (unsigned long) page_address(bvec-bv_page) + bvec-bv_offset; source_addr = dev_info-start + (index12) + bytes_done; - if (unlikely(page_addr 4095) != 0 || (bvec-bv_len 4095) != 0) + if (unlikely((page_addr 4095) != 0) || (bvec-bv_len 4095) != 0) // More paranoia. goto fail; if (bio_data_dir(bio) == READ) { -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/3] drivers/media/video/sn9c102/sn9c102_core.c Fix Unlikely(x) == y
The patch below was not yet tested. If it's incorrect, please comment. --- Fix Unlikely(x) == y Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index c40ba3a..66313b1 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c @@ -528,7 +528,7 @@ sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len) /* Search for the SOF marker (fixed part) in the header */ for (j = 0, b=cam-sof.bytesread; j+b sizeof(marker); j++) { - if (unlikely(i+j) == len) + if (unlikely(i+j == len)) return NULL; if (*(m+i+j) == marker[cam-sof.bytesread]) { cam-sof.header[cam-sof.bytesread] = *(m+i+j); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] kernel/sched.c unlikely(x) || unlikely(y) = unlikely(x || y)
Not yet tested. --- Replace unlikely(x) || unlikely(y) by unlikely(x || y) Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/kernel/sched.c b/kernel/sched.c index f28f19e..816c299 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -137,7 +137,7 @@ static inline void sg_inc_cpu_power(struct sched_group *sg, u32 val) static inline int rt_policy(int policy) { - if (unlikely(policy == SCHED_FIFO) || unlikely(policy == SCHED_RR)) + if (unlikely(policy == SCHED_FIFO || policy == SCHED_RR)) return 1; return 0; } @@ -3832,7 +3832,7 @@ static inline void schedule_debug(struct task_struct *prev) * schedule() atomically, we ignore that path for now. * Otherwise, whine if we are scheduling when we should not be. */ - if (unlikely(in_atomic_preempt_off()) unlikely(!prev-exit_state)) + if (unlikely(in_atomic_preempt_off() !prev-exit_state)) __schedule_bug(prev); profile_hit(SCHED_PROFILING, __builtin_return_address(0)); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] drivers/mtd/onenand/onenand_base.c unlikely(x) || unlikely(y) = unlikely(x || y)
Not yet tested. --- Replace unlikely(x) || unlikely(y) by unlikely(x || y) Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 8d7d21b..7334b4a 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c @@ -1336,7 +1336,7 @@ static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len, } /* Reject writes, which are not page aligned */ -if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(len))) { +if (unlikely(NOTALIGNED(to) || NOTALIGNED(len))) { printk(KERN_ERR onenand_panic_write: Attempt to write not page aligned data\n); return -EINVAL; } @@ -1466,7 +1466,7 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to, } /* Reject writes, which are not page aligned */ -if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(len))) { +if (unlikely(NOTALIGNED(to) || NOTALIGNED(len))) { printk(KERN_ERR onenand_write_ops_nolock: Attempt to write not page aligned data\n); return -EINVAL; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/2] [x86] arch/x86/kernel/signal_32.c: replace !likely(x) by likely(!x)
Roel Kluin wrote: Replace !likely(x) by likely(!x) Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c index caee1f0..335872f 100644 --- a/arch/x86/kernel/signal_32.c +++ b/arch/x86/kernel/signal_32.c @@ -303,7 +303,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size) * If we are on the alternate signal stack and would overflow it, don't. * Return an always-bogus address instead so we will die with SIGSEGV. */ - if (on_sig_stack(sp) !likely(on_sig_stack(sp - frame_size))) + if (on_sig_stack(sp) likely(!on_sig_stack(sp - frame_size))) return (void __user *) -1L; /* This is the X/Open sanctioned signal stack switching. */ -- sorry, please ignore this patch -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] kernel/{exit.c, signal.c, power/process.c}: replace !likely(x) by likely(!x)
H. Peter Anvin wrote: Roel Kluin wrote: Not entirely sure who to send this to --- Replace !likely(x) by likely(!x) Whoa... Are you sure this is correct? !likely(x) is equivalent to unlikely(!x), not the opposite, so this is a functional change... -hpa You are right, sorry, Need more caffeine. I will send the right patch later. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] kernel/{exit.c, signal.c, power/process.c}: replace !likely(x) by likely(!x)
H. Peter Anvin wrote: Roel Kluin wrote: H. Peter Anvin wrote: Roel Kluin wrote: Not entirely sure who to send this to --- Replace !likely(x) by likely(!x) Whoa... Are you sure this is correct? !likely(x) is equivalent to unlikely(!x), not the opposite, so this is a functional change... You are right, sorry, Need more caffeine. I will send the right patch later. Note I didn't say it was wrong, I just wanted a bit more explanation about why it's right, if it is. No, I just wanted to move the '!' within the parentheses, I didn't want to change semantics. below is how I guess the patch should have been. Thanks for your response. --- Replace !likely(x) by unlikely(!x) Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/kernel/signal.c b/kernel/signal.c index 84917fe..cf5d45a 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1308,7 +1308,7 @@ int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p) */ rcu_read_lock(); - if (!likely(lock_task_sighand(p, flags))) { + if (unlikely(!lock_task_sighand(p, flags))) { ret = -1; goto out_err; } @@ -1548,7 +1548,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, int why) static inline int may_ptrace_stop(void) { - if (!likely(current-ptrace PT_PTRACED)) + if (unlikely(!(current-ptrace PT_PTRACED))) return 0; /* * Are we in the middle of do_coredump? @@ -1574,7 +1574,7 @@ static int sigkill_pending(struct task_struct *tsk) { return ((sigismember(tsk-pending.signal, SIGKILL) || sigismember(tsk-signal-shared_pending.signal, SIGKILL)) - !unlikely(sigismember(tsk-blocked, SIGKILL))); +likely(!sigismember(tsk-blocked, SIGKILL))); } /* @@ -1625,7 +1625,7 @@ static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info) spin_unlock_irq(current-sighand-siglock); try_to_freeze(); read_lock(tasklist_lock); - if (!unlikely(killed) may_ptrace_stop()) { + if (likely(!killed) may_ptrace_stop()) { do_notify_parent_cldstop(current, CLD_TRAPPED); read_unlock(tasklist_lock); schedule(); @@ -1717,8 +1717,8 @@ static int do_signal_stop(int signr) } else { struct task_struct *t; - if (!likely(sig-flags SIGNAL_STOP_DEQUEUED) || - unlikely(sig-group_exit_task)) + if (unlikely(!(sig-flags SIGNAL_STOP_DEQUEUED) || + sig-group_exit_task)) return 0; /* * There is no group stop already in progress. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/2] [x86] arch/x86/kernel/signal_32.c: replace !likely(x) by likely(!x)
Roel Kluin wrote: Roel Kluin wrote: Replace !likely(x) by likely(!x) sorry, please ignore this patch The patch below shouldn't change semantics. --- replace !likely(x) by unlikely(!x) Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c index caee1f0..c0fb075 100644 --- a/arch/x86/kernel/signal_32.c +++ b/arch/x86/kernel/signal_32.c @@ -303,7 +303,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size) * If we are on the alternate signal stack and would overflow it, don't. * Return an always-bogus address instead so we will die with SIGSEGV. */ - if (on_sig_stack(sp) !likely(on_sig_stack(sp - frame_size))) + if (on_sig_stack(sp) unlikely(!on_sig_stack(sp - frame_size))) return (void __user *) -1L; /* This is the X/Open sanctioned signal stack switching. */ -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fs/ufs/util.h 2nd parameter of fs32_to_cpu is not boolean
from: fs/befs/endian.h +33 static inline u32 fs32_to_cpu(const struct super_block *sb, fs32 n) { if (BEFS_SB(sb)-byte_order == BEFS_BYTESEX_LE) return le32_to_cpu((__force __le32)n); else return be32_to_cpu((__force __be32)n); } The 2nd parameter is not boolean --- Test the return value, rather than passing a boolean Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/fs/ufs/util.h b/fs/ufs/util.h index b26fc4d..23ceed8 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -58,7 +58,7 @@ ufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, { switch (UFS_SB(sb)-s_flags UFS_ST_MASK) { case UFS_ST_SUNOS: - if (fs32_to_cpu(sb, usb3-fs_postblformat == UFS_42POSTBLFMT)) { + if (fs32_to_cpu(sb, usb3-fs_postblformat) == UFS_42POSTBLFMT) { usb1-fs_u0.fs_sun.fs_state = cpu_to_fs32(sb, value); break; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] arch/sh/drivers/heartbeat.c ioremap is expected to succeed
!unlikely(hd-base) is equivalent to likely(!hd-base) (for instance see comments with commit fd312561adcc90e924f35d3032d5493aeb4c3017), I think the ioremap is expected to succeed? please confirm that's right. The patch below was *not* tested. --- ioremap is expected to succeed Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/arch/sh/drivers/heartbeat.c b/arch/sh/drivers/heartbeat.c index b76a14f..ab77b0e 100644 --- a/arch/sh/drivers/heartbeat.c +++ b/arch/sh/drivers/heartbeat.c @@ -93,7 +93,7 @@ static int heartbeat_drv_probe(struct platform_device *pdev) } hd-base = ioremap_nocache(res-start, res-end - res-start + 1); - if (!unlikely(hd-base)) { + if (unlikely(!hd-base)) { dev_err(pdev-dev, ioremap failed\n); if (!pdev-dev.platform_data) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/3] Fix Unlikely(x) == y
David Howells wrote: Geert Uytterhoeven [EMAIL PROTECTED] wrote: Hence shouldn't we ask the gcc people what's the purpose of __builtin_expect(), if it doesn't live up to its promise? __builtin_expect() is useful on FRV where you _have_ to give each branch and conditional branch instruction a measure of probability whether the branch will be taken. David I was wondering whether some of the uses of likely illustrated below are incorrect or not useful. x = likely(X) || Y for ( ... ; likely(...); ... ) while ( likely(X) ) if ( unlikely(X) /|| likely(Y) ) if ( X /|| unlikely(Y) ) return likely(X); return likely(X) ? a : b; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] wireless: Convert to list_for_each_entry_rcu()
Please verify, this patch was not yet tested. --- Convert list_for_each_rcu() to list_for_each_entry_rcu() Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c index 88efe1b..c5aaab8 100644 --- a/drivers/net/wireless/strip.c +++ b/drivers/net/wireless/strip.c @@ -963,11 +963,12 @@ static char *time_delta(char buffer[], long time) static struct strip *strip_get_idx(loff_t pos) { struct list_head *l; + struct strip *str; int i = 0; - list_for_each_rcu(l, strip_list) { + list_for_each_entry_rcu(str, l, strip_list, list) { if (pos == i) - return list_entry(l, struct strip, list); + return str; ++i; } return NULL; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fs/ext4/mballoc.c: Convert to list_for_each_entry_rcu()
Please verify, this patch was not yet tested --- Convert list_for_each_rcu() to list_for_each_entry_rcu() Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index dd0fcfc..0c4dd13 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3127,6 +3127,7 @@ static void ext4_mb_normalize_request(struct ext4_allocation_context *ac, loff_t size, orig_size, start_off; ext4_lblk_t start, orig_start; struct ext4_inode_info *ei = EXT4_I(ac-ac_inode); + struct ext4_prealloc_space *pa; /* do normalize only data requests, metadata requests do not need preallocation */ @@ -3212,12 +3213,9 @@ static void ext4_mb_normalize_request(struct ext4_allocation_context *ac, /* check we don't cross already preallocated blocks */ rcu_read_lock(); - list_for_each_rcu(cur, ei-i_prealloc_list) { - struct ext4_prealloc_space *pa; + list_for_each_entry_rcu(pa, cur, ei-i_prealloc_list, pa_inode_list) { unsigned long pa_end; - pa = list_entry(cur, struct ext4_prealloc_space, pa_inode_list); - if (pa-pa_deleted) continue; spin_lock(pa-pa_lock); @@ -3259,10 +3257,8 @@ static void ext4_mb_normalize_request(struct ext4_allocation_context *ac, /* XXX: extra loop to check we really don't overlap preallocations */ rcu_read_lock(); - list_for_each_rcu(cur, ei-i_prealloc_list) { - struct ext4_prealloc_space *pa; + list_for_each_entry_rcu(pa, cur, ei-i_prealloc_list, pa_inode_list) { unsigned long pa_end; - pa = list_entry(cur, struct ext4_prealloc_space, pa_inode_list); spin_lock(pa-pa_lock); if (pa-pa_deleted == 0) { pa_end = pa-pa_lstart + pa-pa_len; @@ -3397,8 +3393,7 @@ static int ext4_mb_use_preallocated(struct ext4_allocation_context *ac) /* first, try per-file preallocation */ rcu_read_lock(); - list_for_each_rcu(cur, ei-i_prealloc_list) { - pa = list_entry(cur, struct ext4_prealloc_space, pa_inode_list); + list_for_each_entry_rcu(pa, cur, ei-i_prealloc_list, pa_inode_list) { /* all fields in this condition don't change, * so we can skip locking for them */ @@ -3430,8 +3425,7 @@ static int ext4_mb_use_preallocated(struct ext4_allocation_context *ac) return 0; rcu_read_lock(); - list_for_each_rcu(cur, lg-lg_prealloc_list) { - pa = list_entry(cur, struct ext4_prealloc_space, pa_inode_list); + list_for_each_entry_rcu(pa, cur, lg-lg_prealloc_list, pa_inode_list) { spin_lock(pa-pa_lock); if (pa-pa_deleted == 0 pa-pa_free = ac-ac_o_ex.fe_len) { atomic_inc(pa-pa_count); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] wireless: Convert to list_for_each_entry_rcu()
Roel Kluin wrote: Please verify, this patch was not yet tested. --- Convert list_for_each_rcu() to list_for_each_entry_rcu() Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- Same mistake as in other patch, please ignore the previous patch and consider the patch below. --- Convert list_for_each_rcu() to list_for_each_entry_rcu() Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c index 88efe1b..bced3fe 100644 --- a/drivers/net/wireless/strip.c +++ b/drivers/net/wireless/strip.c @@ -962,12 +962,12 @@ static char *time_delta(char buffer[], long time) /* get Nth element of the linked list */ static struct strip *strip_get_idx(loff_t pos) { - struct list_head *l; + struct strip *str; int i = 0; - list_for_each_rcu(l, strip_list) { + list_for_each_entry_rcu(str, strip_list, list) { if (pos == i) - return list_entry(l, struct strip, list); + return str; ++i; } return NULL; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] fs/ext4/mballoc.c: Convert to list_for_each_entry_rcu()
Aneesh Kumar K.V wrote: On Tue, Feb 19, 2008 at 01:31:18AM +0100, Roel Kluin wrote: Please verify, this patch was not yet tested --- Convert list_for_each_rcu() to list_for_each_entry_rcu() Signed-off-by: Roel Kluin [EMAIL PROTECTED] NACK. This patch doesn't build. You have extra cur in the conversion. Right changes attached. ext4: Convert list_for_each_rcu() to list_for_each_entry_rcu() From: Aneesh Kumar K.V [EMAIL PROTECTED] The list_for_each_entry_rcu() primitive should be used instead of list_for_each_rcu(), as the former is easier to use and provides better type safety. Thanks for your review and correction, Roel -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fix writing to unintended memory in eth16i_probe_port(); drivers/net/eth16i.c
14 is added as an offset to the array dummy_packet (64 unsigned chars) to serve as a destination address in a call to memset(). However, when added, it is automatically scaled by the size of dummy_packet, which is 64. This results in writing to unintended memory. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c index e3dd8b1..1ae0b3e 100644 --- a/drivers/net/eth16i.c +++ b/drivers/net/eth16i.c @@ -680,7 +680,7 @@ static int eth16i_probe_port(int ioaddr) dummy_packet[12] = 0x00; dummy_packet[13] = 0x04; - memset(dummy_packet + 14, 0, sizeof(dummy_packet) - 14); + memset((char *)dummy_packet + 14, 0, sizeof(dummy_packet) - 14); eth16i_select_regbank(2, ioaddr); - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fix writing to unintended memory in pkt_generic_packet(); drivers/block/pktcdvd.c
CDROM_PACKET_SIZE is added as an offset to the pointer to unsigned char cmd[16]. The adjusted pointer is then used as a destination address in a call to memset(). However, when CDROM_PACKET_SIZE is added to the pointer, it is automatically scaled by the size of cmd, which is 16. This results in the call to memset() writing to unintended memory. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index a8130a4..548efcf 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -767,7 +767,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * rq-cmd_len = COMMAND_SIZE(cgc-cmd[0]); memcpy(rq-cmd, cgc-cmd, CDROM_PACKET_SIZE); if (sizeof(rq-cmd) CDROM_PACKET_SIZE) - memset(rq-cmd + CDROM_PACKET_SIZE, 0, sizeof(rq-cmd) - CDROM_PACKET_SIZE); + memset((char *)rq-cmd + CDROM_PACKET_SIZE, 0, sizeof(rq-cmd) - CDROM_PACKET_SIZE); rq-timeout = 60*HZ; rq-cmd_type = REQ_TYPE_BLOCK_PC; - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] fix writing to unintended memory in pkt_generic_packet(); drivers/block/pktcdvd.c
Al Viro wrote: On Tue, Nov 06, 2007 at 11:43:12PM +0100, Roel Kluin wrote: CDROM_PACKET_SIZE is added as an offset to the pointer to unsigned char cmd[16]. The adjusted pointer is then used as a destination address in a call to memset(). However, when CDROM_PACKET_SIZE is added to the pointer, it is automatically scaled by the size of cmd, which is 16. This results in the call to memset() writing to unintended memory. What are you talking about? rq-cmd is an array, not a pointer to array. When it occurs as an argument of +, it decays to pointer to array element. Ok, I misunderstood, but please... Please, learn C. That's not a nice thing to say. - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] fix writing to unintended memory in eth16i_probe_port(); drivers/net/eth16i.c
Al Viro wrote: On Tue, Nov 06, 2007 at 11:57:44PM +0100, Roel Kluin wrote: 14 is added as an offset to the array dummy_packet (64 unsigned chars) to serve as a destination address in a call to memset(). However, when added, it is automatically scaled by the size of dummy_packet, which is 64. This results in writing to unintended memory. NAK. Learn C. yeah I read your other mail, was going to reply myself anyway, but hey, you had to be rude again. - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fix incorrect test in trident_ac97_set(); sound/oss/trident.c
If count reaches zero, the loop ends, but the postfix decrement subtracts it. so, testing for 'count == 0' will not work. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/sound/oss/trident.c b/sound/oss/trident.c index 96adc47..94b5fb4 100644 --- a/sound/oss/trident.c +++ b/sound/oss/trident.c @@ -2939,7 +2939,7 @@ trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val) data |= (mask | (reg AC97_REG_ADDR)); - if (count == 0) { + if (count == -1) { printk(KERN_ERR trident: AC97 CODEC write timed out.\n); spin_unlock_irqrestore(card-lock, flags); return; @@ -2999,7 +2999,7 @@ trident_ac97_get(struct ac97_codec *codec, u8 reg) } while (count--); spin_unlock_irqrestore(card-lock, flags); - if (count == 0) { + if (count == -1) { printk(KERN_ERR trident: AC97 CODEC read timed out.\n); data = 0; } - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] fix incorrect test in trident_ac97_set(); sound/oss/trident.c
Ray Lee wrote: On Nov 7, 2007 10:34 AM, Roel Kluin [EMAIL PROTECTED] wrote: If count reaches zero, the loop ends, but the postfix decrement subtracts it. so, testing for 'count == 0' will not work. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/sound/oss/trident.c b/sound/oss/trident.c index 96adc47..94b5fb4 100644 --- a/sound/oss/trident.c +++ b/sound/oss/trident.c @@ -2939,7 +2939,7 @@ trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val) data |= (mask | (reg AC97_REG_ADDR)); - if (count == 0) { + if (count == -1) { printk(KERN_ERR trident: AC97 CODEC write timed out.\n); spin_unlock_irqrestore(card-lock, flags); return; @@ -2999,7 +2999,7 @@ trident_ac97_get(struct ac97_codec *codec, u8 reg) } while (count--); spin_unlock_irqrestore(card-lock, flags); - if (count == 0) { + if (count == -1) { printk(KERN_ERR trident: AC97 CODEC read timed out.\n); data = 0; } You didn't test this: count is unsigned. Change the loop condition to be --count instead. Ray Yep, you're right, here: -- If count reaches zero, the loop ends, but the postfix decrement still subtracts: testing for 'count == 0' will not work. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- diff --git a/sound/oss/trident.c b/sound/oss/trident.c index 96adc47..6959ee1 100644 --- a/sound/oss/trident.c +++ b/sound/oss/trident.c @@ -2935,7 +2935,7 @@ trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val) do { if ((inw(TRID_REG(card, address)) busy) == 0) break; - } while (count--); + } while (--count); data |= (mask | (reg AC97_REG_ADDR)); @@ -2996,7 +2996,7 @@ trident_ac97_get(struct ac97_codec *codec, u8 reg) data = inl(TRID_REG(card, address)); if ((data busy) == 0) break; - } while (count--); + } while (--count); spin_unlock_irqrestore(card-lock, flags); if (count == 0) { - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
tty: incorrect test of echo_buf() result for ECHO_OP_START
Untested, but this looks like a bug to me --- test echo_buf() result for ECHO_OP_START Signed-off-by: Roel Kluin roel.kl...@gmail.com --- diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 7a744b6..42b6cca 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -767,7 +767,7 @@ static size_t __process_echoes(struct tty_struct *tty) * of echo overrun before the next commit), then discard enough * data at the tail to prevent a subsequent overrun */ while (ldata-echo_commit - tail = ECHO_DISCARD_WATERMARK) { - if (echo_buf(ldata, tail == ECHO_OP_START)) { + if (echo_buf(ldata, tail) == ECHO_OP_START) { if (echo_buf(ldata, tail) == ECHO_OP_ERASE_TAB) tail += 3; else -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] jump_label: unlikely(x) 0
untested, but wasn't this intended instead? -- if (unlikely(x) 0) doesn't seem to help branch prediction Signed-off-by: Roel Kluin roel.kl...@gmail.com --- diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index a507907..cf08540 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -132,14 +132,14 @@ static __always_inline void jump_label_init(void) static __always_inline bool static_key_false(struct static_key *key) { - if (unlikely(atomic_read(key-enabled)) 0) + if (unlikely(atomic_read(key-enabled) 0)) return true; return false; } static __always_inline bool static_key_true(struct static_key *key) { - if (likely(atomic_read(key-enabled)) 0) + if (likely(atomic_read(key-enabled) 0)) return true; return false; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
lockdep: testing '0' where '\0' intended?
Not entirely sure about the assembly part, but shouldn't it... Test for the nul character rather than the '0' (== 0x30), in the __get_user_unknown() case. Signed-off-by: Roel Kluin roel.kl...@gmail.com --- diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c index b2c71c5..71b3aba 100644 --- a/kernel/lockdep_proc.c +++ b/kernel/lockdep_proc.c @@ -632,7 +632,7 @@ static ssize_t lock_stat_write(struct file *file, const char __user *buf, if (get_user(c, buf)) return -EFAULT; - if (c != '0') + if (c != '\0') return count; list_for_each_entry(class, all_lock_classes, lock_entry) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
exynos4: index out of bounds if no pixelcode found
In case no valid pixelcode is found, an i of -1 after the loop is out of bounds for the array. Signed-off-by: Roel Kluin roel.kl...@gmail.com --- diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c b/drivers/media/platform/exynos4-is/fimc-lite-reg.c index 72a343e3b..d0dc7ee 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c +++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c @@ -133,7 +133,7 @@ void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f) int i = ARRAY_SIZE(src_pixfmt_map); u32 cfg; - while (--i = 0) { + while (--i) { if (src_pixfmt_map[i][0] == pixelcode) break; } @@ -240,7 +240,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f) u32 cfg = readl(dev-regs + FLITE_REG_CIODMAFMT); int i = ARRAY_SIZE(pixcode); - while (--i = 0) + while (--i) if (pixcode[i][0] == f-fmt-mbus_code) break; cfg = ~FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] set data enable logic level to low
Signed-off-by: Roel Kluin roel.kl...@gmail.com --- drivers/video/omap2/dss/display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c index fafe7c9..669a81f 100644 --- a/drivers/video/omap2/dss/display.c +++ b/drivers/video/omap2/dss/display.c @@ -266,7 +266,7 @@ void videomode_to_omap_video_timings(const struct videomode *vm, OMAPDSS_SIG_ACTIVE_LOW; ovt-de_level = vm-flags DISPLAY_FLAGS_DE_HIGH ? OMAPDSS_SIG_ACTIVE_HIGH : - OMAPDSS_SIG_ACTIVE_HIGH; + OMAPDSS_SIG_ACTIVE_LOW; ovt-data_pclk_edge = vm-flags DISPLAY_FLAGS_PIXDATA_POSEDGE ? OMAPDSS_DRIVE_SIG_RISING_EDGE : OMAPDSS_DRIVE_SIG_FALLING_EDGE; -- 1.8.1.2 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] unset twsi option3 for gconfig as well
Signed-off-by: Roel Kluin roel.kl...@gmail.com --- drivers/pinctrl/mvebu/pinctrl-dove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index 29f7e4f..360b9b2 100644 --- a/drivers/pinctrl/mvebu/pinctrl-dove.c +++ b/drivers/pinctrl/mvebu/pinctrl-dove.c @@ -335,7 +335,7 @@ static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl *ctrl, unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); gcfg1 = ~DOVE_TWSI_ENABLE_OPTION1; - gcfg2 = ~(DOVE_TWSI_ENABLE_OPTION2 | DOVE_TWSI_ENABLE_OPTION2); + gcfg2 = ~(DOVE_TWSI_ENABLE_OPTION2 | DOVE_TWSI_ENABLE_OPTION3); switch (config) { case 1: -- 1.8.1.2 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] use array_size macro
Please use this one instead. it also removes an unnecessary #define. This patch changes code to use the ARRAY_SIZE macro. This patch is the result of: find -name *.[chsS] | xargs sed -i "s/sizeof(\(\w*\))[ \t]*\/[ \t]*sizeof(\1\[0\])/ARRAY_SIZE(\1)/g" Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> arch/arm/kernel/dma-isa.c |2 +- arch/powerpc/platforms/celleb/scc_sio.c |2 +- arch/um/kernel/tt/ptproxy/ptrace.c | 12 ++-- drivers/char/synclink_gt.c |2 +- drivers/net/apne.c |2 +- drivers/net/arm/am79c961a.c |2 +- drivers/net/atl1/atl1_hw.c |2 +- drivers/net/cs89x0.c|6 +++--- drivers/net/fec_8xx/fec_mii.c |4 ++-- drivers/net/ibm_emac/ibm_emac_debug.c |8 drivers/net/ne-h8300.c |2 +- drivers/net/ne.c|2 +- drivers/net/ne2.c |2 +- drivers/net/ne2k-pci.c |2 +- drivers/net/netxen/netxen_nic_hw.c |2 +- drivers/net/pcmcia/axnet_cs.c |2 +- drivers/net/pcmcia/pcnet_cs.c |2 +- drivers/net/sk98lin/skgesirq.c |2 +- drivers/net/zorro8390.c |2 +- drivers/serial/68328serial.c|4 ++-- drivers/serial/mcfserial.c |7 ++- include/asm-parisc/mmzone.h |2 +- net/atm/proc.c |2 +- 23 files changed, 36 insertions(+), 39 deletions(-) --- diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c index 0a3e9ad..2f080a3 100644 --- a/arch/arm/kernel/dma-isa.c +++ b/arch/arm/kernel/dma-isa.c @@ -216,7 +216,7 @@ void __init isa_init_dma(dma_t *dma) request_dma(DMA_ISA_CASCADE, "cascade"); - for (i = 0; i < sizeof(dma_resources) / sizeof(dma_resources[0]); i++) + for (i = 0; i < ARRAY_SIZE(dma_resources); i++) request_resource(_resource, dma_resources + i); } } diff --git a/arch/powerpc/platforms/celleb/scc_sio.c b/arch/powerpc/platforms/celleb/scc_sio.c index bcd25f5..457651d 100644 --- a/arch/powerpc/platforms/celleb/scc_sio.c +++ b/arch/powerpc/platforms/celleb/scc_sio.c @@ -52,7 +52,7 @@ static int txx9_serial_init(void) if (!node) return 0; - for(i = 0; i < sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) { + for(i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) { if (!(txx9_serial_bitmap & (1<pid, arg4 + 4 * i, regs[i]); return(result); @@ -93,7 +93,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, result = ptrace(PTRACE_GETFPXREGS, child, 0, regs); if(result == -1) return(-errno); - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) ptrace(PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i, regs[i]); return(result); @@ -109,7 +109,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, result = ptrace(PTRACE_GETREGS, child, 0, regs); if(result == -1) return(-errno); - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) ptrace (PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i, regs[i]); return(result); @@ -155,7 +155,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, long regs[FP_FRAME_SIZE]; int i; - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid, arg4 + 4 * i, 0); result = ptrace(PTRACE_SETFPREGS, child, 0, regs); @@ -171,7 +171,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, long regs[FPX_FRAME_SIZE]; int i; - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid, arg4 + 4 * i, 0); result = ptrace(PTRACE_SETFPXREGS, child, 0, regs); @@ -187,7 +187,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, long regs[FRAME_SIZE]; int i; - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) regs[i] = ptrace(P
[PATCH] use array_size macro
This patch changes code to use the ARRAY_SIZE macro. This patch is the result of: find -name *.[chsS] | xargs sed -i "s/sizeof(\(\w*\))[ \t]*\/[ \t]*sizeof(\1\[0\])/ARRAY_SIZE(\1)/g" Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c index 0a3e9ad..2f080a3 100644 --- a/arch/arm/kernel/dma-isa.c +++ b/arch/arm/kernel/dma-isa.c @@ -216,7 +216,7 @@ void __init isa_init_dma(dma_t *dma) request_dma(DMA_ISA_CASCADE, "cascade"); - for (i = 0; i < sizeof(dma_resources) / sizeof(dma_resources[0]); i++) + for (i = 0; i < ARRAY_SIZE(dma_resources); i++) request_resource(_resource, dma_resources + i); } } diff --git a/arch/powerpc/platforms/celleb/scc_sio.c b/arch/powerpc/platforms/celleb/scc_sio.c index bcd25f5..457651d 100644 --- a/arch/powerpc/platforms/celleb/scc_sio.c +++ b/arch/powerpc/platforms/celleb/scc_sio.c @@ -52,7 +52,7 @@ static int txx9_serial_init(void) if (!node) return 0; - for(i = 0; i < sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) { + for(i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) { if (!(txx9_serial_bitmap & (1<pid, arg4 + 4 * i, regs[i]); return(result); @@ -93,7 +93,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, result = ptrace(PTRACE_GETFPXREGS, child, 0, regs); if(result == -1) return(-errno); - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) ptrace(PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i, regs[i]); return(result); @@ -109,7 +109,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, result = ptrace(PTRACE_GETREGS, child, 0, regs); if(result == -1) return(-errno); - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) ptrace (PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i, regs[i]); return(result); @@ -155,7 +155,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, long regs[FP_FRAME_SIZE]; int i; - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid, arg4 + 4 * i, 0); result = ptrace(PTRACE_SETFPREGS, child, 0, regs); @@ -171,7 +171,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, long regs[FPX_FRAME_SIZE]; int i; - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid, arg4 + 4 * i, 0); result = ptrace(PTRACE_SETFPXREGS, child, 0, regs); @@ -187,7 +187,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, long regs[FRAME_SIZE]; int i; - for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++) + for (i = 0; i < ARRAY_SIZE(regs); i++) regs[i] = ptrace(PTRACE_PEEKDATA, debugger->pid, arg4 + 4 * i, 0); result = ptrace(PTRACE_SETREGS, child, 0, regs); diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 2f97d2f..d27001a 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -4717,7 +4717,7 @@ static int register_test(struct slgt_info *info) { static unsigned short patterns[] = {0x, 0x, 0x, 0x, 0x6969, 0x9696}; - static unsigned int count = sizeof(patterns)/sizeof(patterns[0]); + static unsigned int count = ARRAY_SIZE(patterns); unsigned int i; int rc = 0; diff --git a/drivers/net/apne.c b/drivers/net/apne.c index 9541911..8806151 100644 --- a/drivers/net/apne.c +++ b/drivers/net/apne.c @@ -247,7 +247,7 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr) {0x00, NE_EN0_RSARHI}, {E8390_RREAD+E8390_START, NE_CMD}, }; - for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++) { + for (i = 0; i < ARRAY_SIZE(program_seq); i++) { outb(program_seq[i].value, ioaddr + program_seq[i].offset); } diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c index 2143eeb..7796455 100644 ---
Re: [PATCH] use array_size macro
Jeff Dike wrote: > On Fri, Sep 28, 2007 at 12:56:31PM +0200, Roel Kluin wrote: >> arch/um/kernel/tt/ptproxy/ptrace.c | 12 ++-- > > I don't know what you're diffing against, but this file is history in > -mm, and will be gone in mainline after 2.6.23. > > Jeff > Thanks for noting me. I usually pull the masters branch, so my previously submitted patches are against that. Apparently I have to apply the -mm patchset before sending patches. Is there a git branch to pull from for that? Roel - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [rfc-patch 07/11] Text Edit Lock - kprobes architecture independent support
Mathieu Desnoyers wrote: > Use the mutual exclusion provided by the text edit lock in the kprobes code. > It > allows coherent manipulation of the kernel code by other subsystems. > > Signed-off-by: Mathieu Desnoyers <[EMAIL PROTECTED]> > Acked-by: Ananth N Mavinakayanahalli <[EMAIL PROTECTED]> > CC: [EMAIL PROTECTED] > CC: [EMAIL PROTECTED] > CC: [EMAIL PROTECTED] > CC: [EMAIL PROTECTED] > --- > kernel/kprobes.c | 19 +-- > 1 file changed, 13 insertions(+), 6 deletions(-) > > Index: linux-2.6-lttng/kernel/kprobes.c > === > --- linux-2.6-lttng.orig/kernel/kprobes.c 2007-09-07 10:12:06.0 > -0400 > +++ linux-2.6-lttng/kernel/kprobes.c 2007-09-07 10:13:09.0 -0400 > @@ -43,6 +43,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -568,9 +569,10 @@ static int __kprobes __register_kprobe(s > goto out; > } > > + kernel_text_lock(); > ret = arch_prepare_kprobe(p); > if (ret) > - goto out; > + goto out_unlock_text; > > INIT_HLIST_NODE(>hlist); > hlist_add_head_rcu(>hlist, > @@ -578,7 +580,8 @@ static int __kprobes __register_kprobe(s > > if (kprobe_enabled) > arch_arm_kprobe(p); > - > +out_unlock_text: > + kernel_text_unlock(); > out: > mutex_unlock(_mutex); > > @@ -621,8 +624,11 @@ valid_p: >* enabled - otherwise, the breakpoint would already have >* been removed. We save on flushing icache. >*/ > - if (kprobe_enabled) > + if (kprobe_enabled) { > + kernel_text_lock(); > arch_disarm_kprobe(p); > + kernel_text_unlock(); > + } > hlist_del_rcu(_p->hlist); > cleanup_p = 1; > } else { > @@ -644,9 +650,7 @@ valid_p: > list_del_rcu(>list); > kfree(old_p); > } > - mutex_lock(_mutex); > arch_remove_kprobe(p); > - mutex_unlock(_mutex); > } else { > mutex_lock(_mutex); > if (p->break_handler) > @@ -717,7 +721,6 @@ static int __kprobes pre_handler_kretpro > ri->rp = rp; > ri->task = current; > arch_prepare_kretprobe(ri, regs); > - > /* XXX(hch): why is there no hlist_move_head? */ > hlist_del(>uflist); > hlist_add_head(>uflist, >rp->used_instances); > @@ -940,8 +943,10 @@ static void __kprobes enable_all_kprobes > > for (i = 0; i < KPROBE_TABLE_SIZE; i++) { > head = _table[i]; > + kernel_text_lock(); > hlist_for_each_entry_rcu(p, node, head, hlist) > arch_arm_kprobe(p); > + kernel_text_unlock(); > } isn't it better to put the kernel_text_lock around the for loop? > > kprobe_enabled = true; > @@ -969,10 +974,12 @@ static void __kprobes disable_all_kprobe > printk(KERN_INFO "Kprobes globally disabled\n"); > for (i = 0; i < KPROBE_TABLE_SIZE; i++) { > head = _table[i]; > + kernel_text_lock(); > hlist_for_each_entry_rcu(p, node, head, hlist) { > if (!arch_trampoline_kprobe(p)) > arch_disarm_kprobe(p); > } > + kernel_text_unlock(); > } same question here > > mutex_unlock(_mutex); > - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 7/8] UML - add virt_to_pte
Jeff Dike wrote: > Turn um_virt_to_phys into virt_to_pte, cleaning up a horrid interface. > > It's also made non-static and declared in pgtable.h because it'll be > needed when the stubs get a vma. > > Signed-off-by: Jeff Dike <[EMAIL PROTECTED]> > --- > arch/um/kernel/skas/uaccess.c | 56 > +- > include/asm-um/pgtable.h |3 ++ > 2 files changed, 26 insertions(+), 33 deletions(-) > > Index: linux-2.6.22/arch/um/kernel/skas/uaccess.c > === > --- linux-2.6.22.orig/arch/um/kernel/skas/uaccess.c 2007-11-16 > 15:16:54.0 -0500 > +++ linux-2.6.22/arch/um/kernel/skas/uaccess.c2007-11-16 > 15:40:25.0 -0500 > @@ -13,70 +13,60 @@ > #include "kern_util.h" > #include "os.h" > > -static void *um_virt_to_phys(struct task_struct *task, unsigned long addr, > - pte_t *pte_out) > +pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr) > { > pgd_t *pgd; > pud_t *pud; > pmd_t *pmd; > - pte_t *pte; > - pte_t ptent; > > - if (task->mm == NULL) > - return ERR_PTR(-EINVAL); > - pgd = pgd_offset(task->mm, addr); > + if (mm == NULL) > + return NULL; > + > + pgd = pgd_offset(mm, addr); > if (!pgd_present(*pgd)) > - return ERR_PTR(-EINVAL); > + return NULL; > > pud = pud_offset(pgd, addr); > if (!pud_present(*pud)) > - return ERR_PTR(-EINVAL); > + return NULL; > > pmd = pmd_offset(pud, addr); > if (!pmd_present(*pmd)) > - return ERR_PTR(-EINVAL); > - > - pte = pte_offset_kernel(pmd, addr); > - ptent = *pte; > - if (!pte_present(ptent)) > - return ERR_PTR(-EINVAL); > + return NULL; > > - if (pte_out != NULL) > - *pte_out = ptent; > - return (void *) (pte_val(ptent) & PAGE_MASK) + (addr & ~PAGE_MASK); > + return pte_offset_kernel(pmd, addr); > } > > -static unsigned long maybe_map(unsigned long virt, int is_write) > +static pte_t *maybe_map(unsigned long virt, int is_write) > { > - pte_t pte; > - int err; > + pte_t *pte = virt_to_pte(current->mm, virt); > + int err, dummy_code; > > - void *phys = um_virt_to_phys(current, virt, ); > - int dummy_code; > - > - if (IS_ERR(phys) || (is_write && !pte_write(pte))) { > + if ((pte == NULL) || !pte_present(*pte) || > + (is_write && !pte_write(*pte))) { > err = handle_page_fault(virt, 0, is_write, 1, _code); > if (err) > - return -1UL; > - phys = um_virt_to_phys(current, virt, NULL); > + return NULL; > + pte = virt_to_pte(current->mm, virt); > } > - if (IS_ERR(phys)) > - phys = (void *) -1; > + if (!pte_present(*pte)) > + pte = NULL; shouldn't you check again for (pte == NULL)? > > - return (unsigned long) phys; > + return pte; > } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch 08/12] NLM: Fix a circular lock dependency in lockd
Greg KH wrote: @@ -477,10 +479,15 @@ nlmsvc_testlock(struct svc_rqst *rqstp, if (block == NULL) { struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL); + struct nlm_host *host; if (conf == NULL) return nlm_granted; - block = nlmsvc_create_block(rqstp, file, lock, cookie); + /* Create host handle for callback */ + host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len); + if (host == NULL) + return nlm_lck_denied_nolocks; + block = nlmsvc_create_block(rqstp, host, file, lock, cookie); if (block == NULL) { kfree(conf); return nlm_granted; To be frankly I don't know what this is about, but shouldn't conf be freed if host == NULL? - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4] IBM power meter driver
Mark M. Hoffman wrote: >> +static void ibmpex_register_bmc(int iface, struct device *dev) >> +{ >> +struct ibmpex_bmc_data *data; >> +int err; >> + >> +data = kzalloc(sizeof(*data), GFP_KERNEL); >> +if (!data) { >> +printk(KERN_ERR DRVNAME ": Insufficient memory for BMC " >> + "interface %d.\n", data->interface); >> +return; >> +} >> + >> +data->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; >> +data->address.channel = IPMI_BMC_CHANNEL; >> +data->address.data[0] = 0; >> +data->interface = iface; >> +data->bmc_device = dev; >> + >> +/* Create IPMI messaging interface user */ >> +err = ipmi_create_user(data->interface, _data.ipmi_hndlrs, >> + data, >user); >> +if (err < 0) { >> +printk(KERN_ERR DRVNAME ": Error, unable to register user with " >> + "ipmi interface %d\n", >> + data->interface); >> +goto out; >> +} >> + >> +mutex_init(>lock); >> + >> +/* Initialize message */ >> +data->tx_msgid = 0; >> +init_completion(>read_complete); >> +data->tx_message.netfn = PEX_NET_FUNCTION; >> +data->tx_message.cmd = PEX_COMMAND; >> +data->tx_message.data = data->tx_msg_data; >> + >> +/* Does this BMC support PowerExecutive? */ >> +err = ibmpex_ver_check(data); >> +if (err) >> +goto out_user; >> + >> +/* Register the BMC as a HWMON class device */ >> +data->hwmon_dev = hwmon_device_register(data->bmc_device); >> + >> +if (IS_ERR(data->hwmon_dev)) { >> +printk(KERN_ERR DRVNAME ": Error, unable to register hwmon " >> + "class device for interface %d\n", >> + data->interface); >> +kfree(data); >> +return; don't you want to goto out_user here instead? >> +} >> + >> +/* finally add the new bmc data to the bmc data list */ >> +dev_set_drvdata(dev, data); >> +list_add_tail(>list, _data.bmc_data); >> + >> +/* Now go find all the sensors */ >> +err = ibmpex_find_sensors(data); >> +if (err) { >> +printk(KERN_ERR "Error %d allocating memory\n", err); >> +goto out_register; >> +} >> + >> +return; >> + >> +out_register: >> +hwmon_device_unregister(data->hwmon_dev); >> +out_user: >> +ipmi_destroy_user(data->user); >> +out: >> +kfree(data); >> +} - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 09/31] IGET: Stop BFS from using iget() and read_inode() [try #3]
It is very well possible that I misunderstand the locking order here, but FWIW: David Howells wrote: > diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c > index f346eb1..76798c9 100644 > --- a/fs/bfs/inode.c > +++ b/fs/bfs/inode.c > @@ -32,25 +32,29 @@ MODULE_LICENSE("GPL"); > > void dump_imap(const char *prefix, struct super_block * s); > > -static void bfs_read_inode(struct inode * inode) > +struct inode *bfs_iget(struct super_block *sb, unsigned long ino) > { > - unsigned long ino = inode->i_ino; > struct bfs_inode * di; > struct buffer_head * bh; > + struct inode *inode; > int block, off; > > + inode = iget_locked(sb, ino); after this > + if (IS_ERR(inode)) > + return ERR_PTR(-ENOMEM); > + if (!(inode->i_state & I_NEW)) > + return inode; Don't you have to unlock_new_inode(inode) before returning? > + > if (ino < BFS_ROOT_INO || ino > BFS_SB(inode->i_sb)->si_lasti) { > printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino); > - make_bad_inode(inode); > - return; > + goto error; > } > > block = (ino - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1; > bh = sb_bread(inode->i_sb, block); > if (!bh) { > printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id, > ino); > - make_bad_inode(inode); > - return; > + goto error; > } > > off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; > @@ -85,6 +89,12 @@ static void bfs_read_inode(struct inode * inode) > BFS_I(inode)->i_dsk_ino = le16_to_cpu(di->i_ino); /* can be 0 so we > store a copy */ > > brelse(bh); > + unlock_new_inode(inode); > + return inode; > + > +error: and also here? > + iget_failed(inode); > + return ERR_PTR(-EIO); > } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH try #2] Input/Joystick Driver: add support AD7142 joystick driver
Bryan Wu wrote: > +static int ad7142_i2c_read(struct i2c_client *client, unsigned short offset, > + unsigned short *data, unsigned int len) > +{ > + int ret = -1; > + int i; > + u8 block_data[32]; > + > + if (len < 1 && len > 16) { you want || here > + printk(KERN_ERR "AD7142: read data length error\n"); > + return ret; > + } > + > + /* Do raw I2C, not smbus compatible */ > + block_data[0] = (offset & 0xFF00) >> 8; > + block_data[1] = (offset & 0x00FF); > + > + ret = i2c_master_send(client, block_data, 2); > + if (ret < 0) { > + printk(KERN_ERR "AD7142: I2C read error\n"); > + return ret; > + } > + > + ret = i2c_master_recv(client, block_data, len * 2); > + if (ret < 0) { > + printk(KERN_ERR "AD7142: I2C transfer error\n"); > + return ret; > + } > + > + for (i = 0; i < len; i++) { > + unsigned short temp; > + temp = block_data[2 * i]; > + temp = (temp << 8) & 0xFF00; > + *data++ = temp | block_data[2 * i + 1]; > + } > + > + return ret; > +} - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] errors with assignments in if
I am not entirely certain about the third one: from fs/udf/udf_sb.h: #define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat ) if it's the desired behavior then I think this should at least be changed to UDF_SB_VAT(sb) = udf_iget(sb, ino); if (!(UDF_SB_VAT(sb))) --- Errors with assignments in ifs Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index d9af436..e6e85b7 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c @@ -651,7 +651,7 @@ static u32 omap2_get_clksel(u32 *div_sel, u32 *field_mask, break; case CM_SYSCLKOUT_SEL1: div_addr = (u32)_CLKOUT_CTRL; - if ((div_off == 3) || (div_off = 11)) + if ((div_off == 3) || (div_off == 11)) mask= 0x3; break; case CM_CORE_SEL1: diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c index 948a9b2..ed610ed 100644 --- a/drivers/isdn/hisax/elsa.c +++ b/drivers/isdn/hisax/elsa.c @@ -883,7 +883,7 @@ setup_elsa_isa(struct IsdnCard *card) val += 'A' - 3; if (val == 'B' || val == 'C') val ^= 1; - if ((cs->subtyp == ELSA_PCFPRO) && (val = 'G')) + if ((cs->subtyp == ELSA_PCFPRO) && (val == 'G')) val = 'C'; printk(KERN_INFO "Elsa: %s found at %#lx Rev.:%c IRQ %d\n", diff --git a/fs/udf/super.c b/fs/udf/super.c index 4360c7a..353c9e8 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1308,7 +1308,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) if (j == UDF_SB_NUMPARTS(sb)) return 1; - if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino))) + if (!(UDF_SB_VAT(sb) == udf_iget(sb, ino))) return 1; if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) { - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] errors with assignments in if
Roel Kluin wrote: > I am not entirely certain about the third one: > > from fs/udf/udf_sb.h: > > #define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat ) > > if it's the desired behavior then I think this should at least be changed to > > UDF_SB_VAT(sb) = udf_iget(sb, ino); > if (!(UDF_SB_VAT(sb))) On a second glance, I think it's the desired behavior. Use this patch instead. --- Errors with assignments in ifs Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index d9af436..e6e85b7 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c @@ -651,7 +651,7 @@ static u32 omap2_get_clksel(u32 *div_sel, u32 *field_mask, break; case CM_SYSCLKOUT_SEL1: div_addr = (u32)_CLKOUT_CTRL; - if ((div_off == 3) || (div_off = 11)) + if ((div_off == 3) || (div_off == 11)) mask= 0x3; break; case CM_CORE_SEL1: diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c index 948a9b2..ed610ed 100644 --- a/drivers/isdn/hisax/elsa.c +++ b/drivers/isdn/hisax/elsa.c @@ -883,7 +883,7 @@ setup_elsa_isa(struct IsdnCard *card) val += 'A' - 3; if (val == 'B' || val == 'C') val ^= 1; - if ((cs->subtyp == ELSA_PCFPRO) && (val = 'G')) + if ((cs->subtyp == ELSA_PCFPRO) && (val == 'G')) val = 'C'; printk(KERN_INFO "Elsa: %s found at %#lx Rev.:%c IRQ %d\n", - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] return hidden bug
return hidden bug Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644 --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base, arena->size); - return; BUG(); + return; } npages = calc_npages((dma_addr & ~PAGE_MASK) + size); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] return hidden bug
Rik van Riel wrote: > On Mon, 22 Oct 2007 03:05:05 +0200 > Roel Kluin <[EMAIL PROTECTED]> wrote: > >> return hidden bug >> >> Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> >> >> diff --git a/arch/alpha/kernel/pci_iommu.c >> b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644 >> --- a/arch/alpha/kernel/pci_iommu.c >> +++ b/arch/alpha/kernel/pci_iommu.c >> @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t >> dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single: >> dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base, >> arena->size); >> -return; >> BUG(); >> +return; >> } >> >> npages = calc_npages((dma_addr & ~PAGE_MASK) + size); > > BUG() will terminate the process that runs into it, so you can > just remove the return alltogether. If BUG() is hit, the return > will never be reached. > --- hidden bug returns Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c index e1c4707..ca55c33 100644 --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c @@ -365,7 +365,6 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base, arena->size); - return; BUG(); } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] unlock before bug returns
I think the unlock should be before bugging? -- unlock before bug returns Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 5a4cc20..c910170 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -357,9 +357,8 @@ void gpmc_cs_free(int cs) spin_lock(_mem_lock); if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) { printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs); - BUG(); spin_unlock(_mem_lock); - return; + BUG(); } gpmc_cs_disable_mem(cs); release_resource(_cs_mem[cs]); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] unlock before bug returns
Roel Kluin wrote: > unlock before bug returns > if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) { > printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs); > - BUG(); > spin_unlock(_mem_lock); > - return; > + BUG(); should we bother to unlock before panicking, or is the unlock not required either? - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] unlock before bug returns
>> should we bother to unlock before panicking, or is the unlock not >> required either? > > BUG() kills the current process, but not the whole system. > > Unlocking the lock means that the rest of the system has somewhat > of a chance of surviving. Not unlocking means a guaranteed hang > for the rest of the system, making a BUG() no better than panic. > > Please keep the unlock. In that case I guess the pathc below fixes some more unlockings before bugging. in the third patch: maybe BUG before "page_cache_release(page)"? I also spotted some cases where it was attempted to free after BUG(). should that occur before BUG() as well? -- Unlock before BUG() Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 88629a3..679c8b4 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -100,8 +100,10 @@ static ssize_t vol_attribute_show(struct device *dev, ret = sprintf(buf, "%lld\n", vol->used_bytes); else if (attr == _vol_upd_marker) ret = sprintf(buf, "%d\n", vol->upd_marker); - else + else{ + spin_unlock(>ubi->volumes_lock); BUG(); + } spin_unlock(>ubi->volumes_lock); return ret; } diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index e3c8284..67ed205 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -8722,6 +8722,7 @@ static int ipw_wx_get_freq(struct net_device *dev, break; default: + mutex_unlock(>mutex); BUG(); } } else diff --git a/fs/buffer.c b/fs/buffer.c index 76403b1..460c17d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block, return page; failed: - BUG(); unlock_page(page); page_cache_release(page); + BUG(); return NULL; } diff --git a/mm/slab.c b/mm/slab.c index cfa6be4..20c58dc 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1606,8 +1606,10 @@ void __init kmem_cache_init(void) struct kmem_cache *cachep; mutex_lock(_chain_mutex); list_for_each_entry(cachep, _chain, next) - if (enable_cpucache(cachep)) + if (enable_cpucache(cachep)) { + mutex_unlock(_chain_mutex); BUG(); + } mutex_unlock(_chain_mutex); } diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c index 657ee69..c56e773 100644 --- a/net/rxrpc/ar-ack.c +++ b/net/rxrpc/ar-ack.c @@ -752,8 +752,10 @@ all_acked: sp->call = call; rxrpc_get_call(call); spin_lock_bh(>lock); - if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) + if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) { + spin_unlock_bh(>lock); BUG(); + } spin_unlock_bh(>lock); goto process_further; } diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c index 3c04b00..0d30466 100644 --- a/net/rxrpc/ar-call.c +++ b/net/rxrpc/ar-call.c @@ -426,8 +426,10 @@ void rxrpc_release_call(struct rxrpc_call *call) call->rx_first_oos); spin_lock_bh(>lock); - if (test_and_set_bit(RXRPC_CALL_RELEASED, >flags)) + if (test_and_set_bit(RXRPC_CALL_RELEASED, >flags)) { + spin_unlock_bh(>lock); BUG(); + } spin_unlock_bh(>lock); /* dissociate from the socket - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH retry] return hidden bug and unlock bugs
This patches shouldn't alter behavior when CONFIG_BUG is disabled. It is meant as a replacement for the previous patches. Concerning the patch changing fs/buffer.c, I am still wondering whether "page_cache_release(page)" should be placed before or after the BUG(). -- Unlock before BUG(), but don't change behavior in the case when CONFIG_BUG is disabled Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644 --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base, arena->size); - return; BUG(); + return; } npages = calc_npages((dma_addr & ~PAGE_MASK) + size); diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 5a4cc20..12bd0eb 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -357,8 +357,8 @@ void gpmc_cs_free(int cs) spin_lock(_mem_lock); if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) { printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs); - BUG(); spin_unlock(_mem_lock); + BUG(); return; } gpmc_cs_disable_mem(cs); diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 88629a3..e72bead 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -100,8 +100,11 @@ static ssize_t vol_attribute_show(struct device *dev, ret = sprintf(buf, "%lld\n", vol->used_bytes); else if (attr == _vol_upd_marker) ret = sprintf(buf, "%d\n", vol->upd_marker); - else + else { + spin_unlock(>ubi->volumes_lock); BUG(); + return -EINVAL; + } spin_unlock(>ubi->volumes_lock); return ret; } diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index e3c8284..f337578 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -8722,7 +8722,9 @@ static int ipw_wx_get_freq(struct net_device *dev, break; default: + mutex_unlock(>mutex); BUG(); + return -EINVAL; } } else wrqu->freq.m = 0; diff --git a/fs/buffer.c b/fs/buffer.c index 7249e01..90a3785 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block, return page; failed: - BUG(); unlock_page(page); page_cache_release(page); + BUG(); return NULL; } diff --git a/mm/slab.c b/mm/slab.c index cfa6be4..2dd48c1 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1604,11 +1604,16 @@ void __init kmem_cache_init(void) /* 6) resize the head arrays to their final sizes */ { struct kmem_cache *cachep; + int fail = 0; mutex_lock(_chain_mutex); list_for_each_entry(cachep, _chain, next) - if (enable_cpucache(cachep)) + if (enable_cpucache(cachep)) { + fail = 1; + mutex_unlock(_chain_mutex); BUG(); - mutex_unlock(_chain_mutex); + } + if (fail != 1) + mutex_unlock(_chain_mutex); } /* Annotate slab for lockdep -- annotate the malloc caches */ diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c index 657ee69..e551b0b 100644 --- a/net/rxrpc/ar-ack.c +++ b/net/rxrpc/ar-ack.c @@ -752,8 +752,11 @@ all_acked: sp->call = call; rxrpc_get_call(call); spin_lock_bh(>lock); - if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) + if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) { + spin_unlock_bh(>lock); BUG(); + goto process_further; + } spin_unlock_bh(>lock); goto process_further; } diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c index 3c04b00..48804e1 100644 --- a/net/rxrpc/ar-call.c +++ b/net/rxrpc/ar-call.c @@ -426,9 +426,12 @@ void rxrpc_release_call(struct rxrpc_call *call) call->rx_first_oos); spin_lock_bh(>lock); - if (test_and_set_bit(RXRPC_CALL_RELEASED, >flags)) + if (test_and_set_bit(RXRPC_CAL
Re: [PATCH] return hidden bug
Ray Lee wrote: > I'm sorry, perhaps I poured myself a cup of stupid this morning, but > isn't the above patch effectively introducing a BUG where none could > be reached before? In other words, for the patch to have zero > behavioral change, wouldn't it have to remove the BUG() altogether? True, but obviously not intended. I think the intention was to expose this bug. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] return hidden bug
Ray Lee wrote: >>> I'm sorry, perhaps I poured myself a cup of stupid this morning, but >>> isn't the above patch effectively introducing a BUG where none could >>> be reached before? In other words, for the patch to have zero >>> behavioral change, wouldn't it have to remove the BUG() altogether? >> True, but obviously not intended. I think the intention was to expose this >> bug. > > Arguing intentions is very dangerous. I've written code like that > where the intention is to make it simple to turn a printk into a full > bug and back and forth during development. At the end of the day, the > fact remains that you're changing behavior. > > Let me turn this around. Do you have an alpha and have you tried out > your patch? If not, then I'd suggest turning it into a WARN_ON(1) > instead, as in this specific case you're risking turning what was a > working system into one that doesn't. No, I haven't and, I will change it, but it's included with my other changes. see the reply that I'll write shortly for. [PATCH retry] return hidden bug and unlock bugs. Roel - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH retry] return hidden bug and unlock bugs
Roel Kluin wrote: > This patches shouldn't alter behavior when CONFIG_BUG is disabled. It is meant > as a replacement for the previous patches. > > Concerning the patch changing fs/buffer.c, I am still wondering whether > "page_cache_release(page)" should be placed before or after the BUG(). ... > @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t > dma_addr, size_t size, > printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx " > " base %lx size %x\n", dma_addr, arena->dma_base, > arena->size); > - return; > BUG(); > + return; > } As suggested by Ray Lee, BUG() is changed into WARN_ON(1) -- Unlock before BUG(), but don't change behavior in the case when CONFIG_BUG is disabled. Also changes a return-hidden BUG() in a WARN_ON(1) Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c index e1c4707..d04f151 100644 --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c @@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base, arena->size); + WARN_ON(1); return; - BUG(); } npages = calc_npages((dma_addr & ~PAGE_MASK) + size); diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 5a4cc20..12bd0eb 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -357,8 +357,8 @@ void gpmc_cs_free(int cs) spin_lock(_mem_lock); if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) { printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs); - BUG(); spin_unlock(_mem_lock); + BUG(); return; } gpmc_cs_disable_mem(cs); diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 88629a3..e72bead 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -100,8 +100,11 @@ static ssize_t vol_attribute_show(struct device *dev, ret = sprintf(buf, "%lld\n", vol->used_bytes); else if (attr == _vol_upd_marker) ret = sprintf(buf, "%d\n", vol->upd_marker); - else + else { + spin_unlock(>ubi->volumes_lock); BUG(); + return -EINVAL; + } spin_unlock(>ubi->volumes_lock); return ret; } diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index e3c8284..f337578 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -8722,7 +8722,9 @@ static int ipw_wx_get_freq(struct net_device *dev, break; default: + mutex_unlock(>mutex); BUG(); + return -EINVAL; } } else wrqu->freq.m = 0; diff --git a/fs/buffer.c b/fs/buffer.c index 7249e01..90a3785 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1051,9 +1051,9 @@ grow_dev_page(struct block_device *bdev, sector_t block, return page; failed: - BUG(); unlock_page(page); page_cache_release(page); + BUG(); return NULL; } diff --git a/mm/slab.c b/mm/slab.c index cfa6be4..2dd48c1 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1604,11 +1604,16 @@ void __init kmem_cache_init(void) /* 6) resize the head arrays to their final sizes */ { struct kmem_cache *cachep; + int fail = 0; mutex_lock(_chain_mutex); list_for_each_entry(cachep, _chain, next) - if (enable_cpucache(cachep)) + if (enable_cpucache(cachep)) { + fail = 1; + mutex_unlock(_chain_mutex); BUG(); - mutex_unlock(_chain_mutex); + } + if (fail != 1) + mutex_unlock(_chain_mutex); } /* Annotate slab for lockdep -- annotate the malloc caches */ diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c index 657ee69..e551b0b 100644 --- a/net/rxrpc/ar-ack.c +++ b/net/rxrpc/ar-ack.c @@ -752,8 +752,11 @@ all_acked: sp->call = call; rxrpc_get_call(call); spin_lock_bh(>lock); - if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) + if (rxrpc_queue_rcv_skb(call, skb, true, true) < 0) { + spin_unloc
Re: [PATCH] unlock before bug returns
Rene Herman wrote: > On 10/22/2007 02:40 PM, Pekka Enberg wrote: > >> NAK. This will cause double-unlock when CONFIG_BUG is disabled. It's >> incorrect to assume that BUG() will always terminate the current >> process. > > (which by the way also means that the "return;" delete from your > original patch changes behaviour for !CONFIG_BUG, and probably not for > the better). > > Rene. Thanks for your comments. A patch containing this suggestion is: [PATCH retry] return hidden bug and unlock bugs. Roel - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] unlock 12c_mutex before return
unlock 12c_mutex before return -EINVAL Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/media/dvb/dvb-usb/au6610.c b/drivers/media/dvb/dvb-usb/au6610.c index 18e0b16..31f47c7 100644 --- a/drivers/media/dvb/dvb-usb/au6610.c +++ b/drivers/media/dvb/dvb-usb/au6610.c @@ -82,8 +82,10 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], if (mutex_lock_interruptible(>i2c_mutex) < 0) return -EAGAIN; - if (num > 2) + if (num > 2) { +mutex_unlock(>i2c_mutex); return -EINVAL; + } for (i = 0; i < num; i++) { /* write/read request */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] unlock 12c_mutex before return
And a similar one in drivers/media/dvb/dvb-usb/gl861.c -- unlock 12c_mutex before return -EINVAL Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/media/dvb/dvb-usb/gl861.c b/drivers/media/dvb/dvb-usb/gl861.c index f01d99c..20c340a 100644 --- a/drivers/media/dvb/dvb-usb/gl861.c +++ b/drivers/media/dvb/dvb-usb/gl861.c @@ -59,8 +59,10 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], if (mutex_lock_interruptible(>i2c_mutex) < 0) return -EAGAIN; - if (num > 2) + if (num > 2) { + mutex_unlock(>i2c_mutex); return -EINVAL; + } for (i = 0; i < num; i++) { /* write/read request */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] several returns before unlocking in lmc_ioctl
Several returns before unlocking in lmc_ioctl Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index 5ea8772..af7b3e4 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c @@ -142,9 +142,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ * To date internally, just copy this out to the user. */ case LMCIOCGINFO: /*fold01*/ -if (copy_to_user(ifr->ifr_data, >ictl, sizeof (lmc_ctl_t))) -return -EFAULT; -ret = 0; + if (copy_to_user(ifr->ifr_data, >ictl, sizeof(lmc_ctl_t))) + ret = -EFAULT; + else + ret = 0; break; case LMCIOCSINFO: /*fold01*/ @@ -159,8 +160,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } -if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t))) -return -EFAULT; + if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) { + ret = -EFAULT; + break; + } sc->lmc_media->set_status (sc, ); @@ -190,8 +193,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } - if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t))) -return -EFAULT; + if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t))) { + ret = -EFAULT; + break; + } if (new_type == old_type) @@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ sc->lmc_xinfo.Magic1 = 0xDEADBEEF; if (copy_to_user(ifr->ifr_data, >lmc_xinfo, - sizeof (struct lmc_xinfo))) -return -EFAULT; -ret = 0; + sizeof(struct lmc_xinfo))) { + ret = -EFAULT; + else + ret = 0; break; @@ -262,9 +268,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ if (copy_to_user(ifr->ifr_data, >stats, sizeof (struct lmc_statistics))) -return -EFAULT; - -ret = 0; + ret = -EFAULT; + else + ret = 0; break; case LMCIOCCLEARLMCSTATS: /*fold01*/ @@ -292,8 +298,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } -if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t))) -return -EFAULT; + if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) { + ret = -EFAULT; + break; + } sc->lmc_media->set_circuit_type(sc, ctl.circuit_type); sc->ictl.circuit_type = ctl.circuit_type; ret = 0; @@ -318,12 +326,15 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ #ifdef DEBUG case LMCIOCDUMPEVENTLOG: -if (copy_to_user(ifr->ifr_data, , sizeof (u32))) -return -EFAULT; + if (copy_to_user(ifr->ifr_data, , sizeof(u32))) { + ret = -EFAULT; + break; + } if (copy_to_user(ifr->ifr_data + sizeof (u32), lmcEventLogBuf, sizeof (lmcEventLogBuf))) -return -EFAULT; + ret = -EFAULT; + else + ret = 0; -ret = 0; break; #endif /* end ifdef _DBG_EVENTLOG */ case LMCIOCT1CONTROL: /*fold01*/ @@ -346,8 +357,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ */ netif_stop_queue(dev); -if (copy_from_user(, ifr->ifr_data, sizeof (struct lmc_xilinx_control))) -return -EFAULT; + if (copy_from_user(, ifr->ifr_data, sizeof(struct lmc_xilinx_control))) { + ret = -EFAULT; + break; + } switch(xc.command){ case lmc_xilinx_reset: /*fold02*/ { @@ -618,8 +631,8 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ } spin_unlock_irqrestore(>lmc_lock, flags); /*fold01*/ - -lmc_trace(dev, "lmc_ioctl out"); +if (ret >= 0) + lmc_trace(dev, "lmc_ioctl out"); return ret; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Unlock in iTCO_wdt_start when reboot is disabled
commit 61c31efe4e9c34531666a6c5857ecd19c8db Author: Roel Kluin <[EMAIL PROTECTED]> Date: Tue Oct 23 03:08:27 2007 +0200 Unlock in iTCO_wdt_start when reboot is disabled Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index cd5a565..185c093 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c @@ -300,6 +300,7 @@ static int iTCO_wdt_start(void) /* disable chipset's NO_REBOOT bit */ if (iTCO_wdt_unset_NO_REBOOT_bit()) { + spin_unlock(_wdt_private.io_lock); printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); return -EIO; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Unlock before return in p9_mux_poll_start
commit 9f822afc65cc094c905901f9d92bf25042f9ed22 Author: Roel Kluin <[EMAIL PROTECTED]> Date: Tue Oct 23 03:15:55 2007 +0200 Unlock before return in p9_mux_poll_start Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> diff --git a/net/9p/mux.c b/net/9p/mux.c index f140147..c9f0805 100644 --- a/net/9p/mux.c +++ b/net/9p/mux.c @@ -222,8 +222,10 @@ static int p9_mux_poll_start(struct p9_conn *m) } if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) { - if (vptlast == NULL) + if (vptlast == NULL) { + mutex_unlock(_mux_task_lock); return -ENOMEM; + } P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i); list_add(>mux_list, >mux_list); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] several returns before unlocking in lmc_ioctl
I think we should keep the lmc_tracing. Use this patch instead. -- Several returns before unlocking in lmc_ioctl Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index 5ea8772..64eb578 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c @@ -142,9 +142,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ * To date internally, just copy this out to the user. */ case LMCIOCGINFO: /*fold01*/ -if (copy_to_user(ifr->ifr_data, >ictl, sizeof (lmc_ctl_t))) -return -EFAULT; -ret = 0; + if (copy_to_user(ifr->ifr_data, >ictl, sizeof(lmc_ctl_t))) + ret = -EFAULT; + else + ret = 0; break; case LMCIOCSINFO: /*fold01*/ @@ -159,8 +160,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } -if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t))) -return -EFAULT; + if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) { + ret = -EFAULT; + break; + } sc->lmc_media->set_status (sc, ); @@ -190,8 +193,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } - if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t))) -return -EFAULT; + if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t))) { + ret = -EFAULT; + break; + } if (new_type == old_type) @@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ sc->lmc_xinfo.Magic1 = 0xDEADBEEF; if (copy_to_user(ifr->ifr_data, >lmc_xinfo, - sizeof (struct lmc_xinfo))) -return -EFAULT; -ret = 0; + sizeof(struct lmc_xinfo))) { + ret = -EFAULT; + else + ret = 0; break; @@ -262,9 +268,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ if (copy_to_user(ifr->ifr_data, >stats, sizeof (struct lmc_statistics))) -return -EFAULT; - -ret = 0; + ret = -EFAULT; + else + ret = 0; break; case LMCIOCCLEARLMCSTATS: /*fold01*/ @@ -292,8 +298,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } -if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t))) -return -EFAULT; + if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) { + ret = -EFAULT; + break; + } sc->lmc_media->set_circuit_type(sc, ctl.circuit_type); sc->ictl.circuit_type = ctl.circuit_type; ret = 0; @@ -318,12 +326,15 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ #ifdef DEBUG case LMCIOCDUMPEVENTLOG: -if (copy_to_user(ifr->ifr_data, , sizeof (u32))) -return -EFAULT; + if (copy_to_user(ifr->ifr_data, , sizeof(u32))) { + ret = -EFAULT; + break; + } if (copy_to_user(ifr->ifr_data + sizeof (u32), lmcEventLogBuf, sizeof (lmcEventLogBuf))) -return -EFAULT; + ret = -EFAULT; + else + ret = 0; -ret = 0; break; #endif /* end ifdef _DBG_EVENTLOG */ case LMCIOCT1CONTROL: /*fold01*/ @@ -346,8 +357,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ */ netif_stop_queue(dev); -if (copy_from_user(, ifr->ifr_data, sizeof (struct lmc_xilinx_control))) -return -EFAULT; + if (copy_from_user(, ifr->ifr_data, sizeof(struct lmc_xilinx_control))) { + ret = -EFAULT; + break; + } switch(xc.command){ case lmc_xilinx_reset: /*fold02*/ { - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] unlock 12c_mutex before return
Andreas Schwab wrote: >> -if (num > 2) >> +if (num > 2) { >> +mutex_unlock(>i2c_mutex); >> return -EINVAL; > > How about moving the check before the lock? Good suggestion. Patch below covers both previous patches. -- Move check before lock Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/media/dvb/dvb-usb/au6610.c b/drivers/media/dvb/dvb-usb/au6610.c index 18e0b16..f3ff813 100644 --- a/drivers/media/dvb/dvb-usb/au6610.c +++ b/drivers/media/dvb/dvb-usb/au6610.c @@ -79,12 +79,12 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], struct dvb_usb_device *d = i2c_get_adapdata(adap); int i; - if (mutex_lock_interruptible(>i2c_mutex) < 0) - return -EAGAIN; - if (num > 2) return -EINVAL; + if (mutex_lock_interruptible(>i2c_mutex) < 0) + return -EAGAIN; + for (i = 0; i < num; i++) { /* write/read request */ if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { diff --git a/drivers/media/dvb/dvb-usb/gl861.c b/drivers/media/dvb/dvb-usb/gl861.c index f01d99c..6b99d9f 100644 --- a/drivers/media/dvb/dvb-usb/gl861.c +++ b/drivers/media/dvb/dvb-usb/gl861.c @@ -56,12 +56,12 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], struct dvb_usb_device *d = i2c_get_adapdata(adap); int i; - if (mutex_lock_interruptible(>i2c_mutex) < 0) - return -EAGAIN; - if (num > 2) return -EINVAL; + if (mutex_lock_interruptible(>i2c_mutex) < 0) + return -EAGAIN; + for (i = 0; i < num; i++) { /* write/read request */ if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Unlock when ssp tries to close an invalid port
Unlock when ssp tries to close an invalid port Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/arm/mach-pxa/ssp.c b/arch/arm/mach-pxa/ssp.c index 71766ac..422afee 100644 --- a/arch/arm/mach-pxa/ssp.c +++ b/arch/arm/mach-pxa/ssp.c @@ -309,6 +309,7 @@ void ssp_exit(struct ssp_dev *dev) if (dev->port > PXA_SSP_PORTS || dev->port == 0) { printk(KERN_WARNING "SSP: tried to close invalid port\n"); + mutex_unlock(); return; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Fix unlocking before return in gpio
Fix unlocking before return in gpio Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c index f389ed6..0d347a7 100644 --- a/arch/cris/arch-v10/drivers/gpio.c +++ b/arch/cris/arch-v10/drivers/gpio.c @@ -297,8 +297,10 @@ gpio_poll(struct file *file, data = *R_PORT_PB_DATA; else if (priv->minor == GPIO_MINOR_G) data = *R_PORT_G_DATA; - else + else { + spin_unlock(_lock); return 0; + } if ((data & priv->highalarm) || (~data & priv->lowalarm)) { @@ -381,18 +383,21 @@ static ssize_t gpio_write(struct file * file, const char * buf, size_t count, ssize_t retval = count; if (priv->minor !=GPIO_MINOR_A && priv->minor != GPIO_MINOR_B) { - return -EFAULT; + retval = -EFAULT; + goto out; } if (!access_ok(VERIFY_READ, buf, count)) { - return -EFAULT; + retval = -EFAULT; + goto out; } clk_mask = priv->clk_mask; data_mask = priv->data_mask; /* It must have been configured using the IO_CFG_WRITE_MODE */ /* Perhaps a better error code? */ if (clk_mask == 0 || data_mask == 0) { - return -EPERM; + retval = -EPERM; + goto out; } write_msb = priv->write_msb; D(printk("gpio_write: %lu to data 0x%02X clk 0x%02X msb: %i\n",count, data_mask, clk_mask, write_msb)); @@ -425,6 +430,7 @@ static ssize_t gpio_write(struct file * file, const char * buf, size_t count, } } } +out: spin_unlock(_lock); return retval; } @@ -506,6 +512,7 @@ gpio_release(struct inode *inode, struct file *filp) while (p) { if (p->highalarm | p->lowalarm) { gpio_some_alarms = 1; + spin_unlock(_lock); return 0; } p = p->next; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/?] Unlock when sn_oemdata can't be extended
Unlock when sn_oemdata can't be extended Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/ia64/sn/kernel/mca.c b/arch/ia64/sn/kernel/mca.c index 3db62f2..868c9aa 100644 --- a/arch/ia64/sn/kernel/mca.c +++ b/arch/ia64/sn/kernel/mca.c @@ -98,6 +98,7 @@ sn_platform_plat_specific_err_print(const u8 * sect_header, u8 ** oemdata, while (*sn_oemdata_size > sn_oemdata_bufsize) { u8 *newbuf = vmalloc(*sn_oemdata_size); if (!newbuf) { + mutex_unlock(_oemdata_mutex); printk(KERN_ERR "%s: unable to extend sn_oemdata\n", __FUNCTION__); return 1; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] Fix unlock on error
Fix unlock on error Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c index a0a9105..a6e6e78 100644 --- a/arch/mips/kernel/irixsig.c +++ b/arch/mips/kernel/irixsig.c @@ -426,6 +426,7 @@ asmlinkage int irix_sigprocmask(int how, irix_sigset_t __user *new, break; default: + spin_unlock_irq(>sighand->siglock); return -EINVAL; } recalc_sigpending(); diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c index 1899601..11f5f72 100644 --- a/arch/mips/vr41xx/common/icu.c +++ b/arch/mips/vr41xx/common/icu.c @@ -525,6 +525,7 @@ static inline int set_sysint1_assign(unsigned int irq, unsigned char assign) intassign1 |= (uint16_t)assign << 9; break; default: + spin_unlock_irq(>lock); return -EINVAL; } @@ -592,6 +593,7 @@ static inline int set_sysint2_assign(unsigned int irq, unsigned char assign) intassign3 |= (uint16_t)assign << 12; break; default: +spin_unlock_irq(>lock); return -EINVAL; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/?] Unlock when sn_oemdata can't be extended
Several unlocking issues Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/net/9p/mux.c b/net/9p/mux.c index f140147..c9f0805 100644 --- a/net/9p/mux.c +++ b/net/9p/mux.c @@ -222,8 +222,10 @@ static int p9_mux_poll_start(struct p9_conn *m) } if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) { - if (vptlast == NULL) + if (vptlast == NULL) { + mutex_unlock(_mux_task_lock); return -ENOMEM; + } P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i); list_add(>mux_list, >mux_list); diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 817169e..b09c499 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -282,8 +282,10 @@ find_inlist_lock_noload(struct list_head *head, const char *name, int *error, return NULL; list_for_each_entry(e, head, list) { - if (strcmp(e->name, name) == 0) + if (strcmp(e->name, name) == 0) { + mutex_unlock(mutex); return e; + } } *error = -ENOENT; mutex_unlock(mutex); diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 9be1826..cf18097 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -1079,7 +1079,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb, CTA_TUPLE_MASTER, u3); if (err < 0) - return err; + goto out_unlock; master_h = __nf_conntrack_find(, NULL); if (master_h == NULL) { diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 509defe..859fdc0 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -750,8 +750,10 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le rose->neighbour = rose_get_neigh(>srose_addr, , ); - if (!rose->neighbour) - return -ENETUNREACH; + if (!rose->neighbour) { + err = -ENETUNREACH; + goto out_release; + } rose->lci = rose_new_lci(rose->neighbour); if (!rose->lci) { diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c index 23018a7..5b0e9bd 100644 --- a/sound/oss/au1550_ac97.c +++ b/sound/oss/au1550_ac97.c @@ -1833,12 +1833,16 @@ au1550_open(struct inode *inode, struct file *file) } if (file->f_mode & FMODE_READ) { - if ((ret = prog_dmabuf_adc(s))) + if ((ret = prog_dmabuf_adc(s))) { + mutex_unlock(>open_mutex); return ret; + } } if (file->f_mode & FMODE_WRITE) { - if ((ret = prog_dmabuf_dac(s))) + if ((ret = prog_dmabuf_dac(s))) { + mutex_unlock(>open_mutex); return ret; + } } s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); diff --git a/sound/oss/dmasound/dmasound_atari.c b/sound/oss/dmasound/dmasound_atari.c index 285239d..d23a089 100644 --- a/sound/oss/dmasound/dmasound_atari.c +++ b/sound/oss/dmasound/dmasound_atari.c @@ -1276,6 +1276,7 @@ static irqreturn_t AtaInterrupt(int irq, void *dummy) * (almost) like on the TT. */ write_sq_ignore_int = 0; + spin_unlock(); return IRQ_HANDLED; } @@ -1284,6 +1285,7 @@ static irqreturn_t AtaInterrupt(int irq, void *dummy) * the sq variables, so better don't do anything here. */ WAKE_UP(write_sq.sync_queue); + spin_unlock(); return IRQ_HANDLED; } diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 880b824..2f62ad6 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -608,6 +608,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs, /* set the format to the board */ err = mixart_set_format(stream, format); if(err < 0) { + mutex_unlock(>setup_mutex); return err; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/?] Unlock when sn_oemdata can't be extended
This includes some that I think I have reported earlier: in drivers/media/dvb/dvb-usb/au6610.c and drivers/media/dvb/dvb-usb/gl861.c -- Some more unlocking issues Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c index 6be1c57..a6b7ccd 100644 --- a/drivers/char/drm/sis_mm.c +++ b/drivers/char/drm/sis_mm.c @@ -134,6 +134,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, dev_priv->agp_initialized)) { DRM_ERROR ("Attempt to allocate from uninitialized memory manager.\n"); + mutex_unlock(>struct_mutex); return -EINVAL; } diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index 755570c..d607c9e 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c @@ -397,6 +397,7 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr, default: dev_err(>dev, "illegal value for fan divider (%d)\n", div); + mutex_unlock(>update_lock); return -EINVAL; } diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c index 79119f5..bd6da7a 100644 --- a/drivers/macintosh/macio-adb.c +++ b/drivers/macintosh/macio-adb.c @@ -155,6 +155,7 @@ static int macio_adb_reset_bus(void) while ((in_8(>ctrl.r) & ADB_RST) != 0) { if (--timeout == 0) { out_8(>ctrl.r, in_8(>ctrl.r) & ~ADB_RST); + spin_unlock_irqrestore(_lock, flags); return -1; } } diff --git a/drivers/media/dvb/dvb-usb/au6610.c b/drivers/media/dvb/dvb-usb/au6610.c index 18e0b16..f3ff813 100644 --- a/drivers/media/dvb/dvb-usb/au6610.c +++ b/drivers/media/dvb/dvb-usb/au6610.c @@ -79,12 +79,12 @@ static int au6610_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], struct dvb_usb_device *d = i2c_get_adapdata(adap); int i; - if (mutex_lock_interruptible(>i2c_mutex) < 0) - return -EAGAIN; - if (num > 2) return -EINVAL; + if (mutex_lock_interruptible(>i2c_mutex) < 0) + return -EAGAIN; + for (i = 0; i < num; i++) { /* write/read request */ if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { diff --git a/drivers/media/dvb/dvb-usb/gl861.c b/drivers/media/dvb/dvb-usb/gl861.c index f01d99c..6b99d9f 100644 --- a/drivers/media/dvb/dvb-usb/gl861.c +++ b/drivers/media/dvb/dvb-usb/gl861.c @@ -56,12 +56,12 @@ static int gl861_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], struct dvb_usb_device *d = i2c_get_adapdata(adap); int i; - if (mutex_lock_interruptible(>i2c_mutex) < 0) - return -EAGAIN; - if (num > 2) return -EINVAL; + if (mutex_lock_interruptible(>i2c_mutex) < 0) + return -EAGAIN; + for (i = 0; i < num; i++) { /* write/read request */ if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c index edd6828..5478549 100644 --- a/drivers/net/cris/eth_v10.c +++ b/drivers/net/cris/eth_v10.c @@ -1476,6 +1476,7 @@ e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) e100_set_duplex(dev, autoneg); break; default: + spin_unlock(>lock); return -EINVAL; } spin_unlock(>lock); diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index d1131a8..716f532 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c @@ -496,6 +496,7 @@ static int mdc800_usb_probe (struct usb_interface *intf, retval = usb_register_dev(intf, _class); if (retval) { + mutex_unlock(>io_lock); err ("Not able to get a minor for this device."); return -ENODEV; } diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index cd5a565..185c093 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c @@ -300,6 +300,7 @@ static int iTCO_wdt_start(void) /* disable chipset's NO_REBOOT bit */ if (iTCO_wdt_unset_NO_REBOOT_bit()) { + spin_unlock(_wdt_private.io_lock); printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); return -EIO; } diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index 006fc64..37bdef1 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c @@ -153,8 +153,10 @@ static int mmap(struct file *file, struct
[PATCH] fix 'and' typos in drivers/block/pktcdvd.c
Fix two 'and' typos Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index a8130a4..9cd6ba2 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2202,11 +2202,11 @@ static int pkt_media_speed(struct pktcdvd_device *pd, unsigned *speed) return ret; } - if (!buf[6] & 0x40) { + if (!(buf[6] & 0x40)) { printk(DRIVER_NAME": Disc type is not CD-RW\n"); return 1; } - if (!buf[6] & 0x4) { + if (!(buf[6] & 0x4)) { printk(DRIVER_NAME": A1 values on media are not valid, maybe not CDRW?\n"); return 1; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fix 'and' typo in drivers/block/paride/pt.c
Fix 'and' typo (PT_WRITE_OK is defined 2) Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index 9f4e67e..b91accf 100644 --- a/drivers/block/paride/pt.c +++ b/drivers/block/paride/pt.c @@ -664,7 +664,7 @@ static int pt_open(struct inode *inode, struct file *file) goto out; err = -EROFS; - if ((!tape->flags & PT_WRITE_OK) && (file->f_mode & 2)) + if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & 2)) goto out; if (!(iminor(inode) & 128)) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Debugging activated during runtime
Wouldn't it be nice to be able to specify upon loading, or during runtime to modules whether debug messages should be printed? - No kernel recompile needed for debugging. - Less *_DEBUG options required in menuconfig. How I think this could work: Add to the module struct a bool to denote debugging state. If set, pr_debug forwards messages to printk. Another advantage: - A module could be loaded after an unexpected conditions (e.g. after a BUG_ON). Caveats I can see right now: - For modules often loaded during boot this may not be a good solution. Alternatively, instead of a bool for the debug state, the module struct could also get a log-level flag: messages below that level won't be printed. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Debugging activated during runtime
Jan Engelhardt wrote: > On Oct 28 2007 16:15, Roel Kluin wrote: >> Wouldn't it be nice to be able to specify upon loading, or during runtime >> to modules whether debug messages should be printed? > > modprobe ark3116 debug=1 > > Nothing new. Ok, thanks and sorry, I didn't know that. >> - A module could be loaded after an unexpected conditions (e.g. after a >> BUG_ON). > > After a BUG_ON, you are probably next to a panic. Not always, it appears. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fix writing to unintended memory in eth16i_probe_port(); drivers/net/eth16i.c
14 is added as an offset to the array dummy_packet (64 unsigned chars) to serve as a destination address in a call to memset(). However, when added, it is automatically scaled by the size of dummy_packet, which is 64. This results in writing to unintended memory. Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c index e3dd8b1..1ae0b3e 100644 --- a/drivers/net/eth16i.c +++ b/drivers/net/eth16i.c @@ -680,7 +680,7 @@ static int eth16i_probe_port(int ioaddr) dummy_packet[12] = 0x00; dummy_packet[13] = 0x04; - memset(dummy_packet + 14, 0, sizeof(dummy_packet) - 14); + memset((char *)dummy_packet + 14, 0, sizeof(dummy_packet) - 14); eth16i_select_regbank(2, ioaddr); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fix writing to unintended memory in pkt_generic_packet(); drivers/block/pktcdvd.c
CDROM_PACKET_SIZE is added as an offset to the pointer to unsigned char cmd[16]. The adjusted pointer is then used as a destination address in a call to memset(). However, when CDROM_PACKET_SIZE is added to the pointer, it is automatically scaled by the size of cmd, which is 16. This results in the call to memset() writing to unintended memory. Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index a8130a4..548efcf 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -767,7 +767,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * rq->cmd_len = COMMAND_SIZE(cgc->cmd[0]); memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE); if (sizeof(rq->cmd) > CDROM_PACKET_SIZE) - memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE); + memset((char *)rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE); rq->timeout = 60*HZ; rq->cmd_type = REQ_TYPE_BLOCK_PC; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] fix writing to unintended memory in pkt_generic_packet(); drivers/block/pktcdvd.c
Al Viro wrote: > On Tue, Nov 06, 2007 at 11:43:12PM +0100, Roel Kluin wrote: >> CDROM_PACKET_SIZE is added as an offset to the pointer to unsigned char >> cmd[16]. >> The adjusted pointer is then used as a destination address in a call to >> memset(). However, when CDROM_PACKET_SIZE is added to the pointer, it is >> automatically scaled by the size of cmd, which is 16. This results in the >> call >> to memset() writing to unintended memory. > > What are you talking about? rq->cmd is an array, not a pointer to array. > When it occurs as an argument of +, it decays to pointer to array element. Ok, I misunderstood, but please... > Please, learn C. That's not a nice thing to say. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] fix writing to unintended memory in eth16i_probe_port(); drivers/net/eth16i.c
Al Viro wrote: > On Tue, Nov 06, 2007 at 11:57:44PM +0100, Roel Kluin wrote: >> 14 is added as an offset to the array dummy_packet (64 unsigned chars) to >> serve as a destination address in a call to memset(). However, when added, >> it is automatically scaled by the size of dummy_packet, which is 64. This >> results in writing to unintended memory. > > NAK. Learn C. > yeah I read your other mail, was going to reply myself anyway, but hey, you had to be rude again. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] fix incorrect test in trident_ac97_set(); sound/oss/trident.c
If count reaches zero, the loop ends, but the postfix decrement subtracts it. so, testing for 'count == 0' will not work. Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/sound/oss/trident.c b/sound/oss/trident.c index 96adc47..94b5fb4 100644 --- a/sound/oss/trident.c +++ b/sound/oss/trident.c @@ -2939,7 +2939,7 @@ trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val) data |= (mask | (reg & AC97_REG_ADDR)); - if (count == 0) { + if (count == -1) { printk(KERN_ERR "trident: AC97 CODEC write timed out.\n"); spin_unlock_irqrestore(>lock, flags); return; @@ -2999,7 +2999,7 @@ trident_ac97_get(struct ac97_codec *codec, u8 reg) } while (count--); spin_unlock_irqrestore(>lock, flags); - if (count == 0) { + if (count == -1) { printk(KERN_ERR "trident: AC97 CODEC read timed out.\n"); data = 0; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] fix incorrect test in trident_ac97_set(); sound/oss/trident.c
Ray Lee wrote: > On Nov 7, 2007 10:34 AM, Roel Kluin <[EMAIL PROTECTED]> wrote: >> If count reaches zero, the loop ends, but the postfix decrement subtracts it. >> so, testing for 'count == 0' will not work. >> >> Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> >> --- >> diff --git a/sound/oss/trident.c b/sound/oss/trident.c >> index 96adc47..94b5fb4 100644 >> --- a/sound/oss/trident.c >> +++ b/sound/oss/trident.c >> @@ -2939,7 +2939,7 @@ trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 >> val) >> >> data |= (mask | (reg & AC97_REG_ADDR)); >> >> - if (count == 0) { >> + if (count == -1) { >> printk(KERN_ERR "trident: AC97 CODEC write timed out.\n"); >> spin_unlock_irqrestore(>lock, flags); >> return; >> @@ -2999,7 +2999,7 @@ trident_ac97_get(struct ac97_codec *codec, u8 reg) >> } while (count--); >> spin_unlock_irqrestore(>lock, flags); >> >> - if (count == 0) { >> + if (count == -1) { >> printk(KERN_ERR "trident: AC97 CODEC read timed out.\n"); >> data = 0; >> } > > You didn't test this: count is unsigned. Change the loop condition to > be --count instead. > > Ray Yep, you're right, here: -- If count reaches zero, the loop ends, but the postfix decrement still subtracts: testing for 'count == 0' will not work. Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/sound/oss/trident.c b/sound/oss/trident.c index 96adc47..6959ee1 100644 --- a/sound/oss/trident.c +++ b/sound/oss/trident.c @@ -2935,7 +2935,7 @@ trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val) do { if ((inw(TRID_REG(card, address)) & busy) == 0) break; - } while (count--); + } while (--count); data |= (mask | (reg & AC97_REG_ADDR)); @@ -2996,7 +2996,7 @@ trident_ac97_get(struct ac97_codec *codec, u8 reg) data = inl(TRID_REG(card, address)); if ((data & busy) == 0) break; - } while (count--); + } while (--count); spin_unlock_irqrestore(>lock, flags); if (count == 0) { - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] tty_ioctl: Fix the baud_table check in encode_baud_rate
Since you were sending a fix, possibly I shouldn't comment on this. If so please disregard my suggestion for a trivial cleanup. Roel Maciej W. Rozycki wrote: > +void tty_termios_encode_baud_rate(struct ktermios *termios, > + speed_t ibaud, speed_t obaud) > { > int i = 0; > int ifound = -1, ofound = -1; > @@ -251,12 +252,15 @@ void tty_termios_encode_baud_rate(struct > termios->c_cflag &= ~CBAUD; > > do { > - if (obaud - oclose >= baud_table[i] && obaud + oclose <= > baud_table[i]) { > + if (obaud - oclose <= baud_table[i] && > + obaud + oclose >= baud_table[i]) { if(a - b <= c && a + b >= c) if(a <= c + b && a + b >= c) if(c + b >= a && a + b >= c) if(b >= a - c && b >= c - a) true, if: b >= |a - c| so if (oclose >= abs(obaud - baud_table[i])) { should work as well > termios->c_cflag |= baud_bits[i]; > ofound = i; > } > - if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= > baud_table[i]) { > - /* For the case input == output don't set IBAUD bits if > the user didn't do so */ > + if (ibaud - iclose <= baud_table[i] && > + ibaud + iclose >= baud_table[i]) { similarly, if (iclose >= abs(ibaud - baud_table[i])) { > + /* For the case input == output don't set IBAUD bits > +if the user didn't do so */ > if (ofound != i || ibinput) > termios->c_cflag |= (baud_bits[i] << IBSHIFT); > ifound = i; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/4] fix not-and/or errors
if(!x & y) should either be if(!(x & y)) or if(!x && y) I made changes as seemed appropriate, but please review this is against current git. Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c index f569b00..46f156f 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c +++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c @@ -410,7 +410,7 @@ static int parse_mtoken(const char *ptr,unsigned int len, int msk; *valptr = 0; for (idx = 0, msk = 1; valid_bits; idx++, msk <<= 1) { - if (!msk & valid_bits) continue; + if (!(msk & valid_bits)) continue; valid_bits &= ~msk; if (!names[idx]) continue; slen = strlen(names[idx]); diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index 7dce318..65c67d1 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c @@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, int mask) switch (mask) { case MLED_ON: - out = !out & 0x1; + out = !(out & 0x1); break; case GLED_ON: out = (out & 0x1) + 1; diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c index b960f66..6de9d7e 100644 --- a/drivers/s390/cio/cmf.c +++ b/drivers/s390/cio/cmf.c @@ -343,10 +343,10 @@ static int cmf_copy_block(struct ccw_device *cdev) if (sch->schib.scsw.fctl & SCSW_FCTL_START_FUNC) { /* Don't copy if a start function is in progress. */ - if ((!sch->schib.scsw.actl & SCSW_ACTL_SUSPENDED) && + if ((!(sch->schib.scsw.actl & SCSW_ACTL_SUSPENDED)) && (sch->schib.scsw.actl & (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)) && - (!sch->schib.scsw.stctl & SCSW_STCTL_SEC_STATUS)) + (!(sch->schib.scsw.stctl & SCSW_STCTL_SEC_STATUS))) return -EBUSY; } cmb_data = cdev->private->cmb; diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 73c44cb..81943ef 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -2882,7 +2882,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon !(STp->use_pf & PF_TESTED)) { /* Try the other possible state of Page Format if not already tried */ - STp->use_pf = !STp->use_pf | PF_TESTED; + STp->use_pf = !(STp->use_pf | PF_TESTED); st_release_request(SRpnt); SRpnt = NULL; return st_int_ioctl(STp, cmd_in, arg); diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 60a8f55..b64309e 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -335,7 +335,7 @@ static void kick_khubd(struct usb_hub *hub) to_usb_interface(hub->intfdev)->pm_usage_cnt = 1; spin_lock_irqsave(_event_lock, flags); - if (!hub->disconnected & list_empty(>event_list)) { + if (!hub->disconnected && list_empty(>event_list)) { list_add_tail(>event_list, _event_list); wake_up(_wait); } diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c index 1a7d778..1d13dd0 100644 --- a/drivers/video/i810/i810_main.c +++ b/drivers/video/i810/i810_main.c @@ -1476,7 +1476,7 @@ static int i810fb_cursor(struct fb_info *info, struct fb_cursor *cursor) struct i810fb_par *par = info->par; u8 __iomem *mmio = par->mmio_start_virtual; - if (!par->dev_flags & LOCKUP) + if (!(par->dev_flags & LOCKUP)) return -ENXIO; if (cursor->image.width > 64 || cursor->image.height > 64) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 4ba7f0b..ce62c15 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -3946,7 +3946,7 @@ static int __ocfs2_mark_extent_written(struct inode *inode, struct ocfs2_merge_ctxt ctxt; struct ocfs2_extent_list *rightmost_el; - if (!rec->e_flags & OCFS2_EXT_UNWRITTEN) { + if (!(rec->e_flags & OCFS2_EXT_UNWRITTEN)) { ret = -EIO; mlog_errno(ret); goto out; diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 41c76ff..ef09fd2 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -670,7 +670,7 @@ static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *loc { mlog_entry_void(); - BUG_ON((!lockres->l_flags & O
Re: [PATCH 2/4] fix not-and/or errors
Roel Kluin wrote: > if(!x & y) should either be if(!(x & y)) or if(!x && y) > I made changes as seemed appropriate, but please review > > several changes to drivers/net/ > > Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> > hmmm forgot to place '---' here, should I resend? > diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c > index cf70522..14141a5 100644 > --- a/drivers/net/e1000e/82571.c > +++ b/drivers/net/e1000e/82571.c - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/4] fix not-and/or errors
if(!x & y) should either be if(!(x & y)) or if(!x && y) I made changes as seemed appropriate, but please review Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/arm/mach-pxa/mfp.c b/arch/arm/mach-pxa/mfp.c index 5cd3cad..7229319 100644 --- a/arch/arm/mach-pxa/mfp.c +++ b/arch/arm/mach-pxa/mfp.c @@ -199,7 +199,7 @@ void pxa3xx_mfp_set_edge(int mfp, int edge) mfpr_val &= ~MFPR_EDGE_MASK; mfpr_val |= (edge & 0x3u) << MFPR_ERE_OFFSET; - mfpr_val |= (!edge & 0x1) << MFPR_EC_OFFSET; + mfpr_val |= (!(edge & 0x1)) << MFPR_EC_OFFSET; mfpr_writel(mfpr_off, mfpr_val); mfpr_sync(); diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 3d45d24..7d78d22 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -858,7 +858,7 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu) lsapic = (struct acpi_madt_local_sapic *)obj->buffer.pointer; if ((lsapic->header.type != ACPI_MADT_TYPE_LOCAL_SAPIC) || - (!lsapic->lapic_flags & ACPI_MADT_ENABLED)) { + (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))) { kfree(buffer.pointer); return -EINVAL; } diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c index 958bac1..e8f9c85 100644 --- a/arch/sh/drivers/dma/dma-sh.c +++ b/arch/sh/drivers/dma/dma-sh.c @@ -89,7 +89,7 @@ static irqreturn_t dma_tei(int irq, void *dev_id) static int sh_dmac_request_dma(struct dma_channel *chan) { - if (unlikely(!chan->flags & DMA_TEI_CAPABLE)) + if (unlikely(!(chan->flags & DMA_TEI_CAPABLE))) return 0; return request_irq(get_dmte_irq(chan->chan), dma_tei, diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index cd8c740..a2cf955 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c @@ -1070,7 +1070,7 @@ static int set_rtc_mmss(unsigned long nowtime) * Not having a register set can lead to trouble. * Also starfire doesn't have a tod clock. */ - if (!mregs && !dregs & !bregs) + if (!mregs && !dregs && !bregs) return -1; if (mregs) { diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index d915fec..5a67a87 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c @@ -596,7 +596,7 @@ write_led(const char __user * buffer, unsigned long count, (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask); if (invert) /* invert target value */ - led_out = !led_out & 0x1; + led_out = !(led_out & 0x1); if (!write_acpi_int(hotk->handle, ledname, led_out, NULL)) printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9b2c0f7..48fbe9e 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -420,8 +420,8 @@ static int acpi_battery_update(struct acpi_battery *battery, result = acpi_battery_get_status(battery); if (result) goto end; - if ((!battery->flags.battery_present_prev & acpi_battery_present(battery)) - || (battery->flags.battery_present_prev & !acpi_battery_present(battery))) { + if ((!battery->flags.battery_present_prev && acpi_battery_present(battery)) + || (battery->flags.battery_present_prev && !acpi_battery_present(battery))) { result = acpi_battery_init_update(battery); if (result) goto end; diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index 9f4e67e..37079d9 100644 --- a/drivers/block/paride/pt.c +++ b/drivers/block/paride/pt.c @@ -660,11 +660,11 @@ static int pt_open(struct inode *inode, struct file *file) pt_identify(tape); err = -ENODEV; - if (!tape->flags & PT_MEDIA) + if (!(tape->flags & PT_MEDIA)) goto out; err = -EROFS; - if ((!tape->flags & PT_WRITE_OK) && (file->f_mode & 2)) + if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & 2)) goto out; if (!(iminor(inode) & 128)) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/4] fix not-and/or errors
if(!x & y) should either be if(!(x & y)) or if(!x && y) I made changes as seemed appropriate, but please review several changes to drivers/net/ Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c index cf70522..14141a5 100644 --- a/drivers/net/e1000e/82571.c +++ b/drivers/net/e1000e/82571.c @@ -283,7 +283,7 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter *adapter) adapter->flags &= ~FLAG_HAS_WOL; /* quad ports only support WoL on port A */ if (adapter->flags & FLAG_IS_QUAD_PORT && - (!adapter->flags & FLAG_IS_QUAD_PORT_A)) + (!(adapter->flags & FLAG_IS_QUAD_PORT_A))) adapter->flags &= ~FLAG_HAS_WOL; break; diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 074055e..e3eca6d 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -6407,7 +6407,7 @@ static int airo_set_encode(struct net_device *dev, set_wep_key(local, index, NULL, 0, perm, 1); } else /* Don't complain if only change the mode */ - if(!dwrq->flags & IW_ENCODE_MODE) { + if(!(dwrq->flags & IW_ENCODE_MODE)) { return -EINVAL; } } diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 059ce3f..57cc7e5 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c @@ -1759,7 +1759,7 @@ static int atmel_set_encode(struct net_device *dev, priv->default_key = index; } else /* Don't complain if only change the mode */ - if (!dwrq->flags & IW_ENCODE_MODE) { + if (!(dwrq->flags & IW_ENCODE_MODE)) { return -EINVAL; } } diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index c6f5aa3..d93438c 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c @@ -1380,7 +1380,7 @@ static int wlan_get_encodeext(struct net_device *dev, index = adapter->wep_tx_keyidx; } - if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY && + if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) && ext->alg != IW_ENCODE_ALG_WEP) { if (index != 0 || adapter->mode != IW_MODE_INFRA) goto out; diff --git a/drivers/net/wireless/p54common.c b/drivers/net/wireless/p54common.c index 2c63cf0..b67a31e 100644 --- a/drivers/net/wireless/p54common.c +++ b/drivers/net/wireless/p54common.c @@ -374,7 +374,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb) if ((entry_hdr->magic1 & cpu_to_le16(0x4000)) != 0) pad = entry_data->align[0]; - if (!status.control.flags & IEEE80211_TXCTL_NO_ACK) { + if (!(status.control.flags & IEEE80211_TXCTL_NO_ACK)) { if (!(payload->status & 0x01)) status.flags |= IEEE80211_TX_STATUS_ACK; else diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index 6d80ca4..b9d0073 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c @@ -1118,7 +1118,7 @@ prism54_set_encode(struct net_device *ndev, struct iw_request_info *info, mgt_set_request(priv, DOT11_OID_DEFKEYID, 0, ); } else { - if (!dwrq->flags & IW_ENCODE_MODE) { + if (!(dwrq->flags & IW_ENCODE_MODE)) { /* we cannot do anything. Complain. */ return -EINVAL; } @@ -2610,7 +2610,7 @@ prism2_ioctl_set_encryption(struct net_device *dev, mgt_set_request(priv, DOT11_OID_DEFKEYID, 0, ); } else { - if (!param->u.crypt.flags & IW_ENCODE_MODE) { + if (!(param->u.crypt.flags & IW_ENCODE_MODE)) { /* we cannot do anything. Complain. */ return -EINVAL; } diff --git a/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c b/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c index 857dcf3..3c1cca4 100644
Re: [PATCH 3/4] fix not-and/or errors
commit 568f9787e58b4d24be50ab2abf1c7dab12a9ef2c Author: Roel Kluin <[EMAIL PROTECTED]> Date: Wed Oct 17 15:16:44 2007 +0200 if(!x & y) should either be if(!(x & y)) or if(!x && y) I made changes as seemed appropriate, but please review several changes to drivers/isdn/ Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c index ee2b0b9..8325022 100644 --- a/drivers/isdn/act2000/module.c +++ b/drivers/isdn/act2000/module.c @@ -310,7 +310,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c) } break; case ISDN_CMD_DIAL: - if (!card->flags & ACT2000_FLAGS_RUNNING) + if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; if (!(chan = find_channel(card, c->arg & 0x0f))) break; @@ -339,7 +339,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c) } return ret; case ISDN_CMD_ACCEPTD: - if (!card->flags & ACT2000_FLAGS_RUNNING) + if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; if (!(chan = find_channel(card, c->arg & 0x0f))) break; @@ -347,11 +347,11 @@ act2000_command(act2000_card * card, isdn_ctrl * c) actcapi_select_b2_protocol_req(card, chan); return 0; case ISDN_CMD_ACCEPTB: - if (!card->flags & ACT2000_FLAGS_RUNNING) + if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; return 0; case ISDN_CMD_HANGUP: - if (!card->flags & ACT2000_FLAGS_RUNNING) + if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; if (!(chan = find_channel(card, c->arg & 0x0f))) break; @@ -366,7 +366,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c) } return 0; case ISDN_CMD_SETEAZ: - if (!card->flags & ACT2000_FLAGS_RUNNING) + if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; if (!(chan = find_channel(card, c->arg & 0x0f))) break; @@ -386,7 +386,7 @@ act2000_command(act2000_card * card, isdn_ctrl * c) actcapi_listen_req(card); return 0; case ISDN_CMD_CLREAZ: - if (!card->flags & ACT2000_FLAGS_RUNNING) + if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; if (!(chan = find_channel(card, c->arg & 0x0f))) break; @@ -394,14 +394,14 @@ act2000_command(act2000_card * card, isdn_ctrl * c) actcapi_listen_req(card); return 0; case ISDN_CMD_SETL2: - if (!card->flags & ACT2000_FLAGS_RUNNING) + if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; if (!(chan = find_channel(card, c->arg & 0x0f))) break; chan->l2prot = (c->arg >> 8); return 0; case ISDN_CMD_SETL3: - if (!card->flags & ACT2000_FLAGS_RUNNING) + if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; if ((c->arg >> 8) != ISDN_PROTO_L3_TRANS) { printk(KERN_WARNING "L3 protocol unknown\n"); @@ -524,7 +524,7 @@ if_writecmd(const u_char __user *buf, int len, int id, int channel) act2000_card *card = act2000_findcard(id); if (card) { -if (!card->flags & ACT2000_FLAGS_RUNNING) +if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; return (len); } @@ -539,7 +539,7 @@ if_readstatus(u_char __user * buf, int len, int id, int channel) act2000_card *card = act2000_findcard(id); if (card) { -if (!card->flags & ACT2000_FLAGS_RUNNING) +if (!(card->flags & ACT2000
[PATCH 4/4 returns] fix not-and/or errors
Thanks for comments, here a second version with previously covered commits removed Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/arm/mach-pxa/mfp.c b/arch/arm/mach-pxa/mfp.c index 5cd3cad..7229319 100644 --- a/arch/arm/mach-pxa/mfp.c +++ b/arch/arm/mach-pxa/mfp.c @@ -199,7 +199,7 @@ void pxa3xx_mfp_set_edge(int mfp, int edge) mfpr_val &= ~MFPR_EDGE_MASK; mfpr_val |= (edge & 0x3u) << MFPR_ERE_OFFSET; - mfpr_val |= (!edge & 0x1) << MFPR_EC_OFFSET; + mfpr_val |= (!(edge & 0x1)) << MFPR_EC_OFFSET; mfpr_writel(mfpr_off, mfpr_val); mfpr_sync(); diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c index 958bac1..e8f9c85 100644 --- a/arch/sh/drivers/dma/dma-sh.c +++ b/arch/sh/drivers/dma/dma-sh.c @@ -89,7 +89,7 @@ static irqreturn_t dma_tei(int irq, void *dev_id) static int sh_dmac_request_dma(struct dma_channel *chan) { - if (unlikely(!chan->flags & DMA_TEI_CAPABLE)) + if (unlikely(!(chan->flags & DMA_TEI_CAPABLE))) return 0; return request_irq(get_dmte_irq(chan->chan), dma_tei, diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index d915fec..1db2055 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c @@ -596,7 +596,7 @@ write_led(const char __user * buffer, unsigned long count, (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask); if (invert) /* invert target value */ - led_out = !led_out & 0x1; + led_out = !led_out; if (!write_acpi_int(hotk->handle, ledname, led_out, NULL)) printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9b2c0f7..3762ce2 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -420,8 +420,7 @@ static int acpi_battery_update(struct acpi_battery *battery, result = acpi_battery_get_status(battery); if (result) goto end; - if ((!battery->flags.battery_present_prev & acpi_battery_present(battery)) - || (battery->flags.battery_present_prev & !acpi_battery_present(battery))) { + if (battery->flags.battery_present_prev != acpi_battery_present(battery)) { result = acpi_battery_init_update(battery); if (result) goto end; @@ -448,10 +447,7 @@ static void acpi_battery_notify_update(struct acpi_battery *battery) return; } - if ((!battery->flags.battery_present_prev & -acpi_battery_present(battery)) || - (battery->flags.battery_present_prev & -!acpi_battery_present(battery))) { + if (battery->flags.battery_present_prev != acpi_battery_present(battery)) { battery->flags.init_update = 1; } else { battery->flags.update[ACPI_BATTERY_INFO] = 1; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/4] fix not-and/or errors
Al Viro wrote: > On Wed, Oct 17, 2007 at 03:46:43PM +0200, Roel Kluin wrote: >> +++ b/drivers/misc/asus-laptop.c >> @@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, >> int mask) >> >> switch (mask) { >> case MLED_ON: >> -out = !out & 0x1; >> +out = !(out & 0x1); > > Not sure if that's what had been intended. It seems to me if I look at the code, that it's intended to make a bool out of 'out'. That's nonsense because of the precedence the ! will turn it into a boolean before the & 0x1. x = !x & y behaves like x = !x for y != 0. for y = 1 the behavior is even the same for x = !(x & y) so it does not matter in this case, except for clarity. I'll make it out = !out. > >> @@ -2882,7 +2882,7 @@ static int st_int_ioctl(struct scsi_tape *STp, >> unsigned int cmd_in, unsigned lon >> !(STp->use_pf & PF_TESTED)) { >> /* Try the other possible state of Page Format >> if not >> already tried */ >> -STp->use_pf = !STp->use_pf | PF_TESTED; >> +STp->use_pf = !(STp->use_pf | PF_TESTED); > > Wrong. This code, ugly as it is, happens to be correct. Replacement > isn't. I would rewrite it as ^= PF_TESTED | USE_PF; /* remove USE_PF, set * > * PF_TESTED */ > > The rest is covered by Alexey's patch and one I'd posted as followup. ok, thanks, I'll correct and omit these in my follow up patch. Roel - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/4] fix not-and/or errors
previously applied changes removed and changed as suggested. Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index 7dce318..752ae26 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c @@ -322,7 +322,7 @@ static void write_status(acpi_handle handle, int out, int mask) switch (mask) { case MLED_ON: - out = !out & 0x1; + out = !out; break; case GLED_ON: out = (out & 0x1) + 1; diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 73c44cb..289165e 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -2882,7 +2882,8 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon !(STp->use_pf & PF_TESTED)) { /* Try the other possible state of Page Format if not already tried */ - STp->use_pf = !STp->use_pf | PF_TESTED; + STp->use_pf ^= PF_TESTED | USE_PF; /* remove USE_PF, set * + * PF_TESTED */ st_release_request(SRpnt); SRpnt = NULL; return st_int_ioctl(STp, cmd_in, arg); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 9/9] RT: Only dirty a cacheline if the priority is actually changing
Gregory Haskins wrote: > We can avoid dirtying a rq related cacheline with a simple check, so why not. > > Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]> > --- > > 0 files changed, 0 insertions(+), 0 deletions(-) I think you wanted a patch here? - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
build failure, missing libvdeplug.h?
Building uml with an allyesconfig and a few changes in UML only fails with: ... CC arch/um/drivers/vde_user.o /home/roel/dnld/src/kernel/git/linux-2.6/arch/um/drivers/vde_user.c:8:24: error: libvdeplug.h: No such file or directory /home/roel/dnld/src/kernel/git/linux-2.6/arch/um/drivers/vde_user.c: In function 'vde_user_init': /home/roel/dnld/src/kernel/git/linux-2.6/arch/um/drivers/vde_user.c:18: error: 'VDECONN' undeclared (first use in this function) ... the file libvdeplug.h is missing and I can't find it neither in the tree or on the net. 'git-grep VDECONN' shows that VDECONN isn't defined anywhere. this code was added in this commit: -- commit ad43c3565bebada7e5a13288e37542fd940369e8 Author: Jeff Dike <[EMAIL PROTECTED]> Date: Tue Oct 16 01:26:48 2007 -0700 uml: add VDE networking support Added vde network backend in uml to introduce native Virtual Distributed Ethernet support (using libvdeplug). Signed-off-by: Luca Bigliardi <[EMAIL PROTECTED]> Signed-off-by: Jeff Dike <[EMAIL PROTECTED]> Signed-off-by: Andrew Morton <[EMAIL PROTECTED]> Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]> -- There is a reference to http://wiki.virtualsquare.org/index.php/Main_Page in the Kconfig (also added by this commit). After reverting this commit the build continues. possibly the header libvdeplug.h was forgotten? Roel - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: build failure, missing libvdeplug.h?
Roel Kluin wrote: > the file libvdeplug.h is missing > > There is a reference to http://wiki.virtualsquare.org/index.php/Main_Page in > the Kconfig (also added by this commit). > After reverting this commit the build continues. possibly the header > libvdeplug.h was forgotten? Sorry for answering myself, but apparently it can be found here: http://vde.sourceforge.net/ I think, however that there is a 'depends on' missing in kconfig - to prevent build failure? - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 9/16] CRIS architecture: Correct compile errors
Jesper Nilsson wrote: > static int > e100_probe_transceiver(struct net_device* dev) > { > +#if !defined(CONFIG_ETRAX_NO_PHY) > unsigned int phyid_high; > unsigned int phyid_low; > unsigned int oui; > struct transceiver_ops* ops = NULL; > + struct net_local *np = netdev_priv(dev); > + > + spin_lock(>transceiver_lock); > > /* Probe MDIO physical address */ > - for (mdio_phy_addr = 0; mdio_phy_addr <= 31; mdio_phy_addr++) { > - if (e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMSR) != 0x) > + for (np->mii_if.phy_id = 0; np->mii_if.phy_id <= 31; > + np->mii_if.phy_id++) { > + if (e100_get_mdio_reg(dev, > + np->mii_if.phy_id, MII_BMSR) != 0x) > break; > } > - if (mdio_phy_addr == 32) > + if (np->mii_if.phy_id == 32) >return -ENODEV; You need to unlock before this return. > > /* Get manufacturer */ > - phyid_high = e100_get_mdio_reg(dev, mdio_phy_addr, MII_PHYSID1); > - phyid_low = e100_get_mdio_reg(dev, mdio_phy_addr, MII_PHYSID2); > + phyid_high = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_PHYSID1); > + phyid_low = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_PHYSID2); > oui = (phyid_high << 6) | (phyid_low >> 10); > > for (ops = [0]; ops->oui; ops++) { > @@ -998,6 +912,8 @@ > } > transceiver = ops; > > + spin_unlock(>transceiver_lock); > +#endif > return 0; > } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] several returns before unlocking in lmc_ioctl
Kristof Provost wrote: > On 2007-10-23 03:47:48 (+0200), Roel Kluin <[EMAIL PROTECTED]> wrote: >> I think we should keep the lmc_tracing. Use this patch instead. >> >> -- >> Several returns before unlocking in lmc_ioctl >> >> Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> >> --- >> diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c >> index 5ea8772..64eb578 100644 > >> @@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq >> *ifr, int cmd) /*fold00*/ >> sc->lmc_xinfo.Magic1 = 0xDEADBEEF; >> >> if (copy_to_user(ifr->ifr_data, >lmc_xinfo, >> - sizeof (struct lmc_xinfo))) >> -return -EFAULT; >> -ret = 0; >> +sizeof(struct lmc_xinfo))) { >> +ret = -EFAULT; >> +else >> +ret = 0; > I think you have an extra curly brace there. It breaks compile on my > system. You are right. thanks for notifying me and sorry for the trouble. please revert my patch (b463d40cdc436a12799a60a1d6ff1941a70a5bb6) and try instead: -- Several returns before unlocking in lmc_ioctl Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index 5ea8772..427226d 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c @@ -142,9 +142,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ * To date internally, just copy this out to the user. */ case LMCIOCGINFO: /*fold01*/ -if (copy_to_user(ifr->ifr_data, >ictl, sizeof (lmc_ctl_t))) -return -EFAULT; -ret = 0; + if (copy_to_user(ifr->ifr_data, >ictl, sizeof(lmc_ctl_t))) + ret = -EFAULT; + else + ret = 0; break; case LMCIOCSINFO: /*fold01*/ @@ -159,8 +160,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } -if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t))) -return -EFAULT; + if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) { + ret = -EFAULT; + break; + } sc->lmc_media->set_status (sc, ); @@ -190,8 +193,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } - if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t))) -return -EFAULT; + if (copy_from_user(_type, ifr->ifr_data, sizeof(u_int16_t))) { + ret = -EFAULT; + break; + } if (new_type == old_type) @@ -229,9 +234,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ sc->lmc_xinfo.Magic1 = 0xDEADBEEF; if (copy_to_user(ifr->ifr_data, >lmc_xinfo, - sizeof (struct lmc_xinfo))) -return -EFAULT; -ret = 0; + sizeof(struct lmc_xinfo))) + ret = -EFAULT; + else + ret = 0; break; @@ -262,9 +268,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ if (copy_to_user(ifr->ifr_data, >stats, sizeof (struct lmc_statistics))) -return -EFAULT; - -ret = 0; + ret = -EFAULT; + else + ret = 0; break; case LMCIOCCLEARLMCSTATS: /*fold01*/ @@ -292,8 +298,10 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } -if (copy_from_user(, ifr->ifr_data, sizeof (lmc_ctl_t))) -return -EFAULT; + if (copy_from_user(, ifr->ifr_data, sizeof(lmc_ctl_t))) { + ret = -EFAULT; + break; + } sc->lmc_media->set_circuit_type(sc, ctl.circuit_type); sc->ictl.circuit_type = ctl.circuit_type; ret = 0; @@ -318,12 +326,15 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ #ifdef DEBUG case LMCIOCDUMPEVENTLOG: -if (copy_to_user(ifr->ifr_data, , sizeof (u32))) -return -EFAULT; + if (copy_to_user(ifr->ifr_data, , sizeof(u32))) { + ret = -EFAULT; + break; + } if (copy_to_user(ifr->ifr_data + sizeof (u32), lmcEventLogBuf, sizeof (lmcEventLogBuf))) -return -EFAULT; + ret = -EFAULT; + else + ret = 0; -ret = 0; break; #endif /* end ifdef _DBG_EVENTLOG */ case LMCIOCT1CONTROL: /*fold01*/ @@ -
Re: [2.6 patch] fix drivers/net/wan/lmc/ compilation
Adrian Bunk wrote: > Documentation/SubmitChecklist, point 1: > > <-- snip --> > > ... > CC drivers/net/wan/lmc/lmc_main.o > /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/net/wan/lmc/lmc_main.c: In > function ‘lmc_ioctl’: > /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/net/wan/lmc/lmc_main.c:239: > error: expected expression before ‘else’ > ... > make[5]: *** [drivers/net/wan/lmc/lmc_main.o] Error 1 > > <-- snip --> > > Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]> > > --- > d5e92a30491abf073e0a7f4d46b466c7c97f0f61 > diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c > index 64eb578..37c52e1 100644 > --- a/drivers/net/wan/lmc/lmc_main.c > +++ b/drivers/net/wan/lmc/lmc_main.c > @@ -234,7 +234,7 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, > int cmd) /*fold00*/ > sc->lmc_xinfo.Magic1 = 0xDEADBEEF; > > if (copy_to_user(ifr->ifr_data, >lmc_xinfo, > - sizeof(struct lmc_xinfo))) { > + sizeof(struct lmc_xinfo))) > ret = -EFAULT; > else > ret = 0; > I am sorry, my patch broke this and Kristov Provost also noticed this. See http://lkml.org/lkml/2007/10/30/355 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
tty: incorrect test of echo_buf() result for ECHO_OP_START
Untested, but this looks like a bug to me --- test echo_buf() result for ECHO_OP_START Signed-off-by: Roel Kluin --- diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 7a744b6..42b6cca 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -767,7 +767,7 @@ static size_t __process_echoes(struct tty_struct *tty) * of echo overrun before the next commit), then discard enough * data at the tail to prevent a subsequent overrun */ while (ldata->echo_commit - tail >= ECHO_DISCARD_WATERMARK) { - if (echo_buf(ldata, tail == ECHO_OP_START)) { + if (echo_buf(ldata, tail) == ECHO_OP_START) { if (echo_buf(ldata, tail) == ECHO_OP_ERASE_TAB) tail += 3; else -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] jump_label: unlikely(x) > 0
untested, but wasn't this intended instead? -- if (unlikely(x) > 0) doesn't seem to help branch prediction Signed-off-by: Roel Kluin --- diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index a507907..cf08540 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -132,14 +132,14 @@ static __always_inline void jump_label_init(void) static __always_inline bool static_key_false(struct static_key *key) { - if (unlikely(atomic_read(>enabled)) > 0) + if (unlikely(atomic_read(>enabled) > 0)) return true; return false; } static __always_inline bool static_key_true(struct static_key *key) { - if (likely(atomic_read(>enabled)) > 0) + if (likely(atomic_read(>enabled) > 0)) return true; return false; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/