Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3922608pxb; Mon, 4 Oct 2021 12:43:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY+WTY+CobmaNRDa7/5j0u81pDN5+9wEVg1Fh5hxL64wP9GvCmj8gLvRB7d1e7Z1HWE+UN X-Received: by 2002:a05:6402:1e88:: with SMTP id f8mr20156687edf.126.1633376619251; Mon, 04 Oct 2021 12:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633376619; cv=none; d=google.com; s=arc-20160816; b=CYUCWXL4ljml2sLe2oK4WuT/PNHfB35cd+uKvVQ0v9PGeEp1EJJTMZVVU2kiD+uYu7 sTt5+rlLk5u0IiNDHDvL0Zf7teHZnfUGpMQ3VItQCQ7cMPCYCcQD4JTbgbxChvMQvR+v 3jlSuuostVMb4KXpRUzHd1lltZjcDiB/XBuyI1Etlj3NXfOzbKqVL1wbo0kPWRIZ389C f1CxBSGRdrvSxKiUvMDMhSk++5AQwbKgUtWMkX4/JS4nUbw6pv8EtsZcDDUH/vdhc5hf jwU8WcUSvgsTQQVUfNepQBm2MlbymiPlmOSk6GS0uzn4E6GyTki8WDuTcvR8LVQ9kw8l RSoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FGkiFaCRUqV9nQN65kPkHHk8vojPeWz3F6B2aMJRsfg=; b=iGDNytVExr7YabELSIjY9/qFoYLR0iIxlkx9HIc6WwX4OW4agMQIwvWDQmoY++vt+R 4jp0km0s0Xlz+lm50lqHMHVr96m1usanXV6VUb9dyJRwp6EfSIlhyZjez48UGFXn0I57 cjCSTyUREhMa8yyQOt+QeEjsQ3SJuNWVuf7TDJLPRmqjrEpvgkBHcqzTADBl+tdQljbC VpcXn9byuWkglMFvyv+OKUiXHbiXeygiJsYQhJLHLzLZspiBEuD4VdZ9RuO0WQxCQYEH nUB+Y5xYriobe1VPkWx4+XTZTbunLRV5fkyEwIiOn94/+m0/GrnxH7M0g5+6WlPedUtX 2Gfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rVA5avsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r13si7014997edd.214.2021.10.04.12.43.14; Mon, 04 Oct 2021 12:43:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rVA5avsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234688AbhJDNGU (ORCPT + 99 others); Mon, 4 Oct 2021 09:06:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:38830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234685AbhJDNEZ (ORCPT ); Mon, 4 Oct 2021 09:04:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ABC99619E0; Mon, 4 Oct 2021 13:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352424; bh=wyMY1huRCNbpoO8j0Fn8jm0T0PLjaIIMmNDIL1urKvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rVA5avsuL5tUxC9aWO2JOvnqd+9jxXf9roSi6oQjHHoX2xvGXgRbXGYhngm6x42yt 858opVIzFDenwMxge6Mfe1xyxHkmgvS0c+uZTBbMHSTjwF2oQthzcCncq/zadJTr+6 xI63rVgt+fkFXgvXgI3WmGIMF0GycfIA+JJ9abOc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Samuel Iglesias Gonsalvez , Johan Hovold Subject: [PATCH 4.14 56/75] ipack: ipoctal: fix tty registration race Date: Mon, 4 Oct 2021 14:52:31 +0200 Message-Id: <20211004125033.410212330@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125031.530773667@linuxfoundation.org> References: <20211004125031.530773667@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit 65c001df517a7bf9be8621b53d43c89f426ce8d6 upstream. Make sure to set the tty class-device driver data before registering the tty to avoid having a racing open() dereference a NULL pointer. Fixes: 9c1d784afc6f ("Staging: ipack/devices/ipoctal: Get rid of ipoctal_list.") Cc: stable@vger.kernel.org # 3.7 Acked-by: Samuel Iglesias Gonsalvez Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20210917114622.5412-3-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/ipack/devices/ipoctal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -398,13 +398,13 @@ static int ipoctal_inst_slot(struct ipoc spin_lock_init(&channel->lock); channel->pointer_read = 0; channel->pointer_write = 0; - tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL); + tty_dev = tty_port_register_device_attr(&channel->tty_port, tty, + i, NULL, channel, NULL); if (IS_ERR(tty_dev)) { dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n"); tty_port_destroy(&channel->tty_port); continue; } - dev_set_drvdata(tty_dev, channel); } /*