Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754119Ab3GJK2K (ORCPT ); Wed, 10 Jul 2013 06:28:10 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:48677 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753460Ab3GJK2H (ORCPT ); Wed, 10 Jul 2013 06:28:07 -0400 Date: Wed, 10 Jul 2013 11:28:03 +0100 From: Gustavo Padovan To: Adam Lee Cc: linux-bluetooth@vger.kernel.org, Marcel Holtmann , Wen-chien Jesse Sung , AceLan Kao , Tedd Ho-Jeong An , Anthony Wong , Johan Hedberg , open list Subject: Re: [PATCH v3] btusb: fix wrong use of PTR_ERR() Message-ID: <20130710102803.GA2952@joana> Mail-Followup-To: Gustavo Padovan , Adam Lee , linux-bluetooth@vger.kernel.org, Marcel Holtmann , Wen-chien Jesse Sung , AceLan Kao , Tedd Ho-Jeong An , Anthony Wong , Johan Hedberg , open list References: <20130709153213.GC1772@joana> <20130710020212.GA16015@adam-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130710020212.GA16015@adam-laptop> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2686 Lines: 50 Hi Adam, * Adam Lee [2013-07-10 10:02:12 +0800]: > PTR_ERR() returns a signed long type value which is limited by IS_ERR(), > it must be a negative number whose range is [-MAX_ERRNO, 0). > > The bug here returns negative numbers as error codes, then check it by > "if (ret < 0)", but -PTR_ERR() is actually positive. The wrong use here > leads to failure as below, even panic. > > [ 12.958920] Bluetooth: hci0 command 0xfc8e tx timeout > [ 14.961765] Bluetooth: hci0 command 0xfc8e tx timeout > [ 16.964688] Bluetooth: hci0 command 0xfc8e tx timeout > [ 20.954501] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110) > [ 22.957358] Bluetooth: hci0 command 0xfc8e tx timeout > [ 30.948922] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110) > [ 32.951780] Bluetooth: hci0 command 0xfc8e tx timeout > [ 40.943359] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110) > [ 42.946219] Bluetooth: hci0 command 0xfc8e tx timeout > [ 50.937812] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110) > [ 52.940670] Bluetooth: hci0 command 0xfc8e tx timeout > [ 60.932236] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110) > [ 62.935092] Bluetooth: hci0 command 0xfc8e tx timeout > [ 70.926688] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110) > [ 72.929545] Bluetooth: hci0 command 0xfc8e tx timeout > [ 80.921111] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-110) > [ 82.923969] Bluetooth: hci0 command 0xfc2f tx timeout > [ 90.915542] Bluetooth: hci0 sending Intel patch command (0xfc2f) failed (-110) > [ 92.918406] Bluetooth: hci0 command 0xfc11 tx timeout > [ 100.909955] Bluetooth: hci0 sending Intel patch command (0xfc11) failed (-110) > [ 102.912858] Bluetooth: hci0 command 0xfc60 tx timeout > [ 110.904394] Bluetooth: hci0 sending Intel patch command (0xfc60) failed (-110) > [ 112.907293] Bluetooth: hci0 command 0xfc11 tx timeout > [ 120.898831] Bluetooth: hci0 exiting Intel manufacturer mode failed (-110) > [ 120.904757] bluetoothd[1030]: segfault at 4 ip 00007f8b2eb55236 sp 00007fff53ff6920 error 4 in bluetoothd[7f8b2eaff000+cb000] > > Signed-off-by: Adam Lee > --- > drivers/bluetooth/btusb.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) Patch has been applied to bluetooth.git. Thanks. Gustavo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/