Thread (12 messages) read the whole thread 12 messages, 5 authors, 2013-07-10

Re: [PATCH] btusb: fix overflow return values

From: Adam Lee <hidden>
Date: 2013-07-09 02:55:12
Also in: lkml

On Mon, Jul 08, 2013 at 11:50:54AM -0700, Marcel Holtmann wrote:
Hi Adam,
quoted
PTR_ERR() returns a long type value, but btusb_setup_intel() and
btusb_setup_intel_patching() should return an int type value.

This bug makes the judgement "if (ret < 0)" not working on x86_64
architecture systems, leading to failure as below, even panic.
...
For not affecting other modules, I choose to modify the return values
but not extend btusb_setup_intel() and btusb_setup_intel_patching()'s
return types. This is harmless, because the return values were only
used to comparing number 0.
there are tons of examples in various subsystems and drivers where we
return PTR_ERR from a function calls returning int.

So I wonder what is actually going wrong here. If this is x86_64
specific problem with PTR_ERR vs int, then we should have this problem
everywhere in the kernel.
Hi, Marcel

I see you point, the difference between here and other subsystems are:

1, it returns -PTR_ERR() here but all other places return PTR_ERR(), I
checked.
2, the judgement is "if (ret < 0)" here but other places are "if (ret)".

I'm not saying other subsystems are 100% right, but here, returning
-PTR_ERR() and checking "if (ret < 0)" make the judgement broken much
much more easily.

I attached a testing C file, run it on x86_64, you will see the bug.

PS, about other subsystems, I also think returning PTR_ERR() from a
function calls returning int considered harmful sometimes, will talk
about that in other thread.

Great thanks.

-- 
Regards,
Adam Lee
Hardware Enablement

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help