Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp871177img; Thu, 21 Mar 2019 10:40:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyR1dS+7Bnte3iUwRAgtELPUiVIPgi4+SNqp1qOoAk4STkLx6Jr8Xgp4R1umlxW3PUYcDG X-Received: by 2002:a63:535c:: with SMTP id t28mr4488695pgl.128.1553190001669; Thu, 21 Mar 2019 10:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553190001; cv=none; d=google.com; s=arc-20160816; b=MYsjG/76Cm1+gtM++mK3H1POKHIulmQpcyWRSWyypYQnMedvdmAPaXEVky+WifMWhd ZJTuj3W+1SY8AJ8dX+eh3PfIXahgZbA3BSU9y/k7Y6ULJwpvDbPjA1icp6nbY3wR1XW3 ddWQcBpvy3TrYnFadracEdjwBGn1m+TfJPCUSeSU0XPjwTzgDeQEYDpFBCfSIkJUTsKy D9IDdGPJ2mAhIfsEw4IE+umL9uAwX35w5Bo7KPupY2mZpzThfUpPKCvfAFKmtNa0D/gm Zh8l3Ayf2392nHJ5mV8eHa68kfnh2DxbTC+h/UC8zdHZACj/tXs9/OLjjrENJuPe9BAz rM9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pbDxp5GkA+9vqwldMbnOT2iQxIrmPHLML9xJjuPErUY=; b=LIC95xb/Miv4Y8/puJCZ3NVGTFqZoPOw1X3ro2gDu0RcnK8fclCI9STpMylm432GWv rKIdFcBzHo98lM0laBRir4If4eBHd4ITvj5+kOFwNWqUh+vLQP+EuRHoQWQTFC0yvCI1 kGR8CGNlriKUxLp/mskOr24Vz6VmT3KEX5gXy0WWyZ5PjuWqWZ4gz+6tSMacDhZKNJs/ ZGvj17vgA3DEdO5siKSKz9DRi+VW2Bd//QfFDzhQj+Ud9SwrMGKdnIvtygdosa+qKsgq 9gm1vsle89ompSRrHd91phjJvFs1BDinWpguUzhmtamvEVtnTw368tehn920TOr2tDhH yDsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yj8wP2EB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si4487208pgp.364.2019.03.21.10.39.43; Thu, 21 Mar 2019 10:40:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yj8wP2EB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728602AbfCURiv (ORCPT + 99 others); Thu, 21 Mar 2019 13:38:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:58000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727987AbfCURiv (ORCPT ); Thu, 21 Mar 2019 13:38:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D81E321874; Thu, 21 Mar 2019 17:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553189930; bh=C7iD2l6U3+bXbfetdCeQyXVq9YDemrRkixz6M6zrTSY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yj8wP2EBwSOFOs4dM6tjyxMsacqwQFEKIBlvQZphyMCX43+xNphXkRlnoiSn+crCA lWuqoFqJcIA1BoKpPEAh2skfMpt4i1XNUTjwCGG1D01+SG5jkHxTxWKgZoEqJuR9D3 7+nXGt84hP80TaxP+7ohAHlKI8guLdgR3FjXwGjU= Date: Thu, 21 Mar 2019 18:38:47 +0100 From: Greg Kroah-Hartman To: Fabien Dessenne Cc: Jiri Slaby , linux-kernel@vger.kernel.org, Benjamin Gaignard Subject: Re: [PATCH] tty: fix NULL pointer issue when tty_port ops is not set Message-ID: <20190321173847.GA7032@kroah.com> References: <1553183006-12820-1-git-send-email-fabien.dessenne@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1553183006-12820-1-git-send-email-fabien.dessenne@st.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 04:43:26PM +0100, Fabien Dessenne wrote: > Unlike 'client_ops' which is initialized to 'default_client_ops', the > port operations 'ops' may be left to NULL. > Check the 'ops' value before checking the 'ops->x' value. > > Signed-off-by: Fabien Dessenne > --- > drivers/tty/tty_port.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c > index 044c3cb..a9e12b3 100644 > --- a/drivers/tty/tty_port.c > +++ b/drivers/tty/tty_port.c > @@ -325,7 +325,7 @@ static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) > if (tty && C_HUPCL(tty)) > tty_port_lower_dtr_rts(port); > > - if (port->ops->shutdown) > + if (port->ops && port->ops->shutdown) > port->ops->shutdown(port); > } > out: > @@ -398,7 +398,7 @@ EXPORT_SYMBOL_GPL(tty_port_tty_wakeup); > */ > int tty_port_carrier_raised(struct tty_port *port) > { > - if (port->ops->carrier_raised == NULL) > + if (!port->ops || !port->ops->carrier_raised) > return 1; > return port->ops->carrier_raised(port); > } > @@ -414,7 +414,7 @@ EXPORT_SYMBOL(tty_port_carrier_raised); > */ > void tty_port_raise_dtr_rts(struct tty_port *port) > { > - if (port->ops->dtr_rts) > + if (port->ops && port->ops->dtr_rts) > port->ops->dtr_rts(port, 1); > } > EXPORT_SYMBOL(tty_port_raise_dtr_rts); > @@ -429,7 +429,7 @@ EXPORT_SYMBOL(tty_port_raise_dtr_rts); > */ > void tty_port_lower_dtr_rts(struct tty_port *port) > { > - if (port->ops->dtr_rts) > + if (port->ops && port->ops->dtr_rts) > port->ops->dtr_rts(port, 0); > } > EXPORT_SYMBOL(tty_port_lower_dtr_rts); > @@ -684,7 +684,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty, > > if (!tty_port_initialized(port)) { > clear_bit(TTY_IO_ERROR, &tty->flags); > - if (port->ops->activate) { > + if (port->ops && port->ops->activate) { > int retval = port->ops->activate(port, tty); > if (retval) { > mutex_unlock(&port->mutex); > -- > 2.7.4 > Can you hit this today with any in-kernel drivers? Or is this only for your new code you are adding? thanks, greg k-h