Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F11FAC05027 for ; Wed, 8 Feb 2023 14:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230482AbjBHOzA (ORCPT ); Wed, 8 Feb 2023 09:55:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231200AbjBHOy6 (ORCPT ); Wed, 8 Feb 2023 09:54:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A1B1526E; Wed, 8 Feb 2023 06:54:57 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4961EB81E4B; Wed, 8 Feb 2023 14:54:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DE0AC433EF; Wed, 8 Feb 2023 14:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675868095; bh=K40VKH6bWRcTPucEbgvdvZ7YJ9QWhZmDNw3iO+juPTQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=haMS9in0rEpld9hSRQ82B81Wm8lh+JahXvz2gXG5redQdEQOc2xMzKHrZU50VhvZf 2T8VTBkFSikHFJyHUKag3r2i0YLSnSLWYyIPWkwzZHweh+rIv5NU83daQCHVoZvLfw KoCH7EbxS2GbjXXPOxUAJv4tuG8leQx2VkCewIJI= Date: Wed, 8 Feb 2023 15:54:52 +0100 From: Greg Kroah-Hartman To: Prashanth K Cc: Christophe JAILLET , Xiu Jianfeng , Pratham Pratap , Jack Pham , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: gadget: u_serial: Add null pointer check in gserial_resume Message-ID: References: <1675864487-18620-1-git-send-email-quic_prashk@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1675864487-18620-1-git-send-email-quic_prashk@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 08, 2023 at 07:24:47PM +0530, Prashanth K wrote: > Consider a case where gserial_disconnect has already cleared > gser->ioport. And if a wakeup interrupt triggers afterwards, > gserial_resume gets called, which will lead to accessing of > gserial->port and thus causing null pointer dereference.Add > a null pointer check to prevent this. > > Fixes: aba3a8d01d62 (" usb: gadget: u_serial: add suspend resume callbacks") Nit, and our tools will complain, no " " before the "usb:" string here, right? > Signed-off-by: Prashanth K > --- > drivers/usb/gadget/function/u_serial.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c > index 840626e..98be2b8 100644 > --- a/drivers/usb/gadget/function/u_serial.c > +++ b/drivers/usb/gadget/function/u_serial.c > @@ -1428,6 +1428,9 @@ void gserial_resume(struct gserial *gser) > struct gs_port *port = gser->ioport; > unsigned long flags; > > + if (!port) > + return; > + What prevents port from going to NULL right after this check? thanks, greg k-h