Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2776774yba; Mon, 22 Apr 2019 12:46:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZDH9D8KWw5G1CpdjDFEgvR2C/Qfw9ZkBp1WLmY1JeatHLn/oplPWqJcF854L5g75A/jmA X-Received: by 2002:a65:5049:: with SMTP id k9mr19985315pgo.229.1555962363555; Mon, 22 Apr 2019 12:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555962363; cv=none; d=google.com; s=arc-20160816; b=E0mkUvfHmaveQAYJfiCapu7oilwU9ovV57PKXtyJt8PhHcaKj8yZapXJEkgv9XRj2s 03l8eaX7aaxaHsN7OkCilUi1h/0Tb8n/A0sEkh23zhnHusBCaWEj0z/lEb/DBDYzQzEG 3DYI15AP5r87uqVeWsE3lGVfNB9GwNXtBC8d0d2PqEYP8HVmxFY4GLCEYvpD/3EEfh1O 7VJlLnTy12/yVSm1IAmYOZkmjG3/mU0MToVXmw7D0U26VNAiH7BzkipOkMkfX9jY/8bM HXzPde1loY1lFJbFpgx4hcYGOrzJmJTmKc9MBV1FMY6kudJGuz/TsRmhiLl4M8nOd26S PCuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=39oxkXmy2jx6yMd75lKcX59mZlZQMz+m4GPdq0/sruA=; b=dlgDbuqyA+OnJzW7zdT7SIWLhwF6+m7rVz7eaSOMxERUETjRmKV8lK64QeNL2s+Jfh eh8DcGwSsYD12j3bBqEZbBwEfOnLKUAk1f8qVJteoSYS89UUP/fzVbLgiAetkc5dIgnv 09bkc7RUzWNM8l1yA1P8AImXrp1QpZkxM7V58qaarQ5LIKpwNHNHc9xP0uRTJc7AIftt 7GB5tNpREaFw2E08a+JeoVGzFOQAxxSwvEppL7NR/g+nHdIZq2lQZyEDqQ/fMkynRI8L O+UkPaic750bDD1sYM3ayRfEsN4sO29qxCAXO5Gn6Gfxte4QpNWbzhheNgOAxeZa7/Or YRcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1cREnGMo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si12959011pgl.380.2019.04.22.12.45.48; Mon, 22 Apr 2019 12:46:03 -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=1cREnGMo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729462AbfDVTo1 (ORCPT + 99 others); Mon, 22 Apr 2019 15:44:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:45380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728922AbfDVToV (ORCPT ); Mon, 22 Apr 2019 15:44:21 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E41F1218FF; Mon, 22 Apr 2019 19:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962260; bh=rrXXp4PphF24lBaeRNQ2aUqDnqBx2R6T+V1WBb5Kd0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1cREnGMoJJ7wfjMqWHaNhjGbtXxWcMIjUdD4Ill3v6LYYK0oiV7IsxdiizxkENiNE R1DLuC8v+17hu6YkvMS7O6aO0JnUhiHm6XUGZLM3x0IMmShUghsLVXtgzp/NeDT/NH MhqhHMjD83V4wjPPNb2zqJuMZbWB0qaDLWIlLj5U= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Fabien Dessenne , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 5.0 70/98] tty: fix NULL pointer issue when tty_port ops is not set Date: Mon, 22 Apr 2019 15:41:37 -0400 Message-Id: <20190422194205.10404-70-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194205.10404-1-sashal@kernel.org> References: <20190422194205.10404-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabien Dessenne [ Upstream commit f4e68d58cf2b20a581759bbc7228052534652673 ] 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin (Microsoft) --- 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 044c3cbdcfa4..a9e12b3bc31d 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.19.1