Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2972347yba; Mon, 22 Apr 2019 16:56:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJGViPW+v/LsR3lVxDPuFXRXIqJ41xMGIRy4+UEkKIlxobnzbn59QUy49CiJCj+ibMH2L1 X-Received: by 2002:a63:1446:: with SMTP id 6mr12871308pgu.227.1555977371405; Mon, 22 Apr 2019 16:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555977371; cv=none; d=google.com; s=arc-20160816; b=GNhmSqscGgV0YZCtvKPW8a8Z2FLhjdQu8sndhOxGs1WLg2kX8ErdKehmQorKE4+Kxo YPrY64oV5Arcv1s2j/7A28b2m0oPTmboi0/miwY1BpCdK+gMZiz1Dhy/QQA3l7lTy8nX Y0/35Le+LNnIRElT6Mx1sqBTOHF7UlzrddcT9vi2RjRjjkM+XnjxZ1pWptNEIwGrFZZu QO9MLBxmMXvtiPyxGkkQCPlLGRuroAZsM8sYtCsz/IkjmTSeKlHGlhMSxaRYpHlaLlav CRDMupumA0kFDt+RtBFsmCA3xaDik7Yt36D1kmYgvodTnQ+Z35G48AB6V7FpboKmzvb1 mKzQ== 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=8ewxD39cP2Nh4/WpHbKSLKQmS+b+TIk6U9lWILOTgcI=; b=UeKmJNf1EXfJBxynt6JEiz9Nr6oW1ME662L1kQI4B8HJwCCb7bixGdMw8+iJ2lfYIv 3p3+tww+7Tfq1/fSZi9nJ1maEptBqVqcJ3lJXOY+DryTN5yUdpcOPpJXgsmzihTnLYM9 3IOzQQsKzyYbY64eYpzqY+bkxDF1/V1S/c0JHOjqKPJr1jRcOWf16sNztiAk5uicAavn 7/gGHTU+KuTLFhUDeTtvRAiEn3jA7YnqQh1chwQ8ZweK7w3PUG40N9afVi9vjqNkiEx0 ONNqb3tRl4jTS8s5nhDMKPOuMS6LYk3c6Qme1FSNRISE/fyCT1eSxZNp+9dSxBMUITO7 j2Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=piHwFFje; 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 o3si14444143pld.61.2019.04.22.16.55.56; Mon, 22 Apr 2019 16:56:11 -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=piHwFFje; 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 S1731931AbfDVUBA (ORCPT + 99 others); Mon, 22 Apr 2019 16:01:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:49780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729686AbfDVTrH (ORCPT ); Mon, 22 Apr 2019 15:47:07 -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 566A821907; Mon, 22 Apr 2019 19:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962427; bh=+WSBRJDrN03D1uNtUm521wsHkaYa0fQK4p+AdFAQBYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=piHwFFje/PbjSSlicI3lNli4B/zUvxvryzZxa6htwhGidJx+c/HFCMird7mDHBayA I2AQOYVGMvPBIk+xAgqMhcFBdJAQ/f/ftFvpsN2t9D9Y8pF4uMPPUQhi0W6iKwDKoN ry1466vOPdDfc+QlgtvU8dDKE5MwELvtZ1qZJ8HE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Fabien Dessenne , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 56/68] tty: fix NULL pointer issue when tty_port ops is not set Date: Mon, 22 Apr 2019 15:45:04 -0400 Message-Id: <20190422194516.11634-56-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-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 c699d41a2a48..81b23905c544 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -327,7 +327,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: @@ -402,7 +402,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); } @@ -419,7 +419,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); @@ -435,7 +435,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); @@ -691,7 +691,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