Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3803497pxb; Mon, 4 Oct 2021 09:56:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ6s78VNMY6NVc/kll2ugd0Yo//tpr7pqawkRhGFXSERzRUIePA5Xm9phpDyBh9A4UcQ2d X-Received: by 2002:a17:90b:4c92:: with SMTP id my18mr15447548pjb.246.1633366607971; Mon, 04 Oct 2021 09:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633366607; cv=none; d=google.com; s=arc-20160816; b=Mo/0yMMB/McacWld7RPv6DDidmTTb01nbSfVpc/T9J7jyHdeP74A5JoQVzhDtyqana 8J4BLNlSmrP4HyXjTCWTMTY3ZeRyDxY4FDRumOhOfUkOsyCzTh/9Mm4Yjk/5bYuDNvHM hWLhE8x8MvBGHBXqaBrbglwFMrw5sj4xF0fbvdPUQN44Nz27q7r/1zq0C/7HgAJxdda7 uTK/2jsNObu8X4WPVdVrV+mOodlLPWv+1O7E8ho1T3Si3Co7AIYSKphm58WEOsQ1o7xp OVgzMMHn9aJj+A7cRGmvOR5KOMgFkPhy3tytbI+gqz1YR81vlQg8Mb+/EAAObWd5pCt8 rIDg== 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=m+GBrBn4BnJxW+vXtDOrsOTvb+602ege9jM8Qc3PdAs=; b=XkoBvLyjCU2ASm1mHWlqldgrJVm0SbdaGvFd2cQEYZ3ZQQPeA9qTx+idqhlcxoHNYc tXZgHpoWjmC/td0VCy5SNJ90nmcVqzTjxDAArRew7zUm10DKDJ1ZaILLCNt7e8Wbtfq9 6XHlyCmtVJY7xGlHuki12ZH+ZuJtMMyOjmdL6Xr/JHngZZz8FhXEUuAzlISHv8Hsy3QO TYz5dzybCcz9s/6h0AnyZ7qLRFo9QKxy5DZacttcCED+leMWFKnVomPQyH6oIH7/nQl6 bD0zAhMn6wSOxTSaFnnWW/awqjMyi22xcjvJCbCbNdn2XLbtpZ/YCXjZAD3z4q1UBKBA P0dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QNX5IrnQ; 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 w189si5000335pgd.426.2021.10.04.09.56.34; Mon, 04 Oct 2021 09:56:47 -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=QNX5IrnQ; 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 S238026AbhJDNlj (ORCPT + 99 others); Mon, 4 Oct 2021 09:41:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:54580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238244AbhJDNkK (ORCPT ); Mon, 4 Oct 2021 09:40:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E219E63246; Mon, 4 Oct 2021 13:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353491; bh=O2IwRnTwwoWWJ7JCSAtvN+FgjoL7fhVWaMuWqUpB6gE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QNX5IrnQ45P+mZp9/Wxzs66LOjktR+/cgRWUR1Olc7GkrFGqEv+4e1LWzYjvY4+/Y UulgkP/QFM+J/RMAT4jlL2Wq37mx46bBwacqUc81VZ2XqZCFeKeavohXEv7Tr0i2/Q iY+1TchOpb/wcOFjMqdKZoXhJnOwNhGnD0ZoZaho= 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 5.14 149/172] ipack: ipoctal: fix tty registration race Date: Mon, 4 Oct 2021 14:53:19 +0200 Message-Id: <20211004125049.776300870@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@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 @@ -393,13 +393,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); } /*