Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3295670iob; Mon, 16 May 2022 18:29:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj0bdNDWSmibkF72IZcRMj/0DzLioywGweYdJEQ32SnJcz3UgaFAtyPO4VL2TdnzMfWfu5 X-Received: by 2002:a05:6a00:24d5:b0:50d:eea9:507 with SMTP id d21-20020a056a0024d500b0050deea90507mr20381315pfv.15.1652750941273; Mon, 16 May 2022 18:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652750941; cv=none; d=google.com; s=arc-20160816; b=hIT5jGOZzS9oy23ALr1u6khSDcqDnX9+6bhkN1uzV1gyK6YflqfONdV2EvEdC4LDu7 0suNsGQQMH3tlPmMjnXeWgwLYQwebTEGoc5DDi9fSwR914Cqa1nBmYQ0+mBVW8Lgn+zd yvfigO7CRcrW/sYe70l8khKFUoSNAtPtASbrlSh9URGBphXbaXRg2zu0gWiSwYwiIV56 1OYSJNrPEZZkEFxTH1utHIS4p3lqW0hwT7eefaf6cqPAJmCZvEX2r43EvAYrSh6VO/wV Mge3CYDTl9e5pTgBbAC0t7gJ6els2wv5gbEBhgBtRapRoB0tjFvgyS+mTPqiRYOixspp ZEiQ== 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=LS8j5+KnqA1HPv3m/6MgmtwdE57cc1/n29iWxe8Puw0=; b=iIS54KVyN5f9zVgkCP8np10aQJ/ORbYlz8UGdWJU6Ed7h6YOF9APHwIJHRItmlsaE5 euuSovmzl+gdvHH/yOZb+4B75hS0czgOveqOxb5urq9E86MyPOybfHtrK43yvVARdXAt a4RhrK1EXvoJV9hV+sNEfAOe5KX3jnhPbzDlEi2TK8zfdAFU0Owa2dcTeThY2iREICdO YS2Ucvu7i5iX4nJ0ebuF83tTLzA5zbBBymYMp08kk+3EBtNOQqRH/d7mPvEDiYyPW4H1 8vssdb59v8KpJN/PScMpugRp+6JOMwVFkm9FPenTB24wt3l2/19bKUd/MEnftLb6NJqC SQzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZqnKFbws; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a056a0021cb00b004fa3a8dffa1si16031586pfj.88.2022.05.16.18.28.49; Mon, 16 May 2022 18:29:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZqnKFbws; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1345063AbiEPURh (ORCPT + 99 others); Mon, 16 May 2022 16:17:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348749AbiEPT6u (ORCPT ); Mon, 16 May 2022 15:58:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E8349CB8; Mon, 16 May 2022 12:50:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 24ACE60BBB; Mon, 16 May 2022 19:50:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CD9EC34100; Mon, 16 May 2022 19:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730657; bh=tp+iY+5N+WnKZV1bBz/lKDeRyBo9XckND8D3YCkF+Ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZqnKFbwsqgH0q/cEiXH44HqauNs3KfVOW5kb6ufwm7aF3w7ZEbPuFKIZONlu2fSZs B6tNWn/yFJyilXfKbzsZBOuVvAlY19muzumuA2KPjU4aAdwSvkzVTJqoHARFVtgrY2 Ko94z8WgELS46s+XyyEFi7DLIJqxO9xdGQaJ3i54= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.15 069/102] tty: n_gsm: fix mux activation issues in gsm_config() Date: Mon, 16 May 2022 21:36:43 +0200 Message-Id: <20220516193625.977305084@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193623.989270214@linuxfoundation.org> References: <20220516193623.989270214@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Starke commit edd5f60c340086891fab094ad61270d6c80f9ca4 upstream. The current implementation activates the mux if it was restarted and opens the control channel if the mux was previously closed and we are now acting as initiator instead of responder, which is the default setting. This has two issues. 1) No mux is activated if we keep all default values and only switch to initiator. The control channel is not allocated but will be opened next which results in a NULL pointer dereference. 2) Switching the configuration after it was once configured while keeping the initiator value the same will not reopen the control channel if it was closed due to parameter incompatibilities. The mux remains dead. Fix 1) by always activating the mux if it is dead after configuration. Fix 2) by always opening the control channel after mux activation. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220504081733.3494-2-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_gsm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2276,6 +2276,7 @@ static void gsm_copy_config_values(struc static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c) { + int ret = 0; int need_close = 0; int need_restart = 0; @@ -2343,10 +2344,13 @@ static int gsm_config(struct gsm_mux *gs * FIXME: We need to separate activation/deactivation from adding * and removing from the mux array */ - if (need_restart) - gsm_activate_mux(gsm); - if (gsm->initiator && need_close) - gsm_dlci_begin_open(gsm->dlci[0]); + if (gsm->dead) { + ret = gsm_activate_mux(gsm); + if (ret) + return ret; + if (gsm->initiator) + gsm_dlci_begin_open(gsm->dlci[0]); + } return 0; }