From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755906AbbIUCs4 (ORCPT ); Sun, 20 Sep 2015 22:48:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:8569 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752330AbbIUCsz (ORCPT ); Sun, 20 Sep 2015 22:48:55 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,565,1437462000"; d="scan'208";a="809021429" Subject: Re: [PATCH] USB: EHCI: fix dereference of ERR_PTR To: Sudip Mukherjee , Alan Stern , Greg Kroah-Hartman References: <1442412485-1944-1-git-send-email-sudipm.mukherjee@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org From: "Lu, Baolu" Message-ID: <55FF7014.3010903@linux.intel.com> Date: Mon, 21 Sep 2015 10:48:52 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442412485-1944-1-git-send-email-sudipm.mukherjee@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/16/2015 10:08 PM, Sudip Mukherjee wrote: > On error find_tt() returns either a NULL pointer or the error value in > ERR_PTR. But we were dereferencing it directly without even checking if > find_tt() returned a valid pointer or not. > > Signed-off-by: Sudip Mukherjee > --- > drivers/usb/host/ehci-sched.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c > index f9a3327..27bced7 100644 > --- a/drivers/usb/host/ehci-sched.c > +++ b/drivers/usb/host/ehci-sched.c > @@ -257,6 +257,8 @@ static void reserve_release_intr_bandwidth(struct ehci_hcd *ehci, > /* FS/LS bus bandwidth */ > if (tt_usecs) { > tt = find_tt(qh->ps.udev); > + if (!tt || IS_ERR(tt)) Why not IS_ERR_OR_NULL()? > + return; > if (sign > 0) > list_add_tail(&qh->ps.ps_list, &tt->ps_list); > else > @@ -1373,6 +1375,8 @@ static void reserve_release_iso_bandwidth(struct ehci_hcd *ehci, > } > > tt = find_tt(stream->ps.udev); > + if (!tt || IS_ERR(tt)) > + return; > if (sign > 0) > list_add_tail(&stream->ps.ps_list, &tt->ps_list); > else