linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adam Lee <adam.lee@canonical.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-bluetooth@vger.kernel.org,
	Wen-chien Jesse Sung <jesse.sung@canonical.com>,
	AceLan Kao <acelan.kao@canonical.com>,
	Tedd Ho-Jeong An <tedd.an@intel.com>,
	Anthony Wong <anthony.wong@canonical.com>,
	Gustavo Padovan <gustavo@padovan.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] btusb: fix overflow return values
Date: Tue, 9 Jul 2013 15:40:39 +0800	[thread overview]
Message-ID: <20130709074039.GA25268@adam-laptop> (raw)
In-Reply-To: <20130709025501.GA6369@adam-laptop>

On Tue, Jul 09, 2013 at 10:55:01AM +0800, Adam Lee wrote:
> On Mon, Jul 08, 2013 at 11:50:54AM -0700, Marcel Holtmann wrote:
> > Hi Adam,
> > 
> > > 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.

Hi, all

After diving into the err.h, I realized this patch contains some
modifications which are actually not necessary. Will submit a v2
version and explain.

PS, other subsystems are using it right, this not.

-- 
Regards,
Adam Lee
Hardware Enablement

  reply	other threads:[~2013-07-09  7:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-04 12:43 [PATCH] btusb: fix overflow return values Adam Lee
2013-07-05  2:37 ` Yang Bai
2013-07-05  2:53   ` Yang Bai
2013-07-05  2:59   ` Adam Lee
2013-07-05  4:41     ` Adam Lee
2013-07-08 18:50 ` Marcel Holtmann
2013-07-09  2:55   ` Adam Lee
2013-07-09  7:40     ` Adam Lee [this message]
2013-07-09  8:48       ` [PATCH v2] btusb: fix wrong use of PTR_ERR() Adam Lee
2013-07-09 15:32     ` [PATCH] btusb: fix overflow return values Gustavo Padovan
2013-07-10  2:02       ` [PATCH v3] btusb: fix wrong use of PTR_ERR() Adam Lee
2013-07-10 10:28         ` Gustavo Padovan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130709074039.GA25268@adam-laptop \
    --to=adam.lee@canonical.com \
    --cc=acelan.kao@canonical.com \
    --cc=anthony.wong@canonical.com \
    --cc=gustavo@padovan.org \
    --cc=jesse.sung@canonical.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=tedd.an@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).