Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7424749rwi; Mon, 24 Oct 2022 14:34:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM700lyr9b9PvE3LqQcmyYkynedfOmL7D+nnzpMiC/ym5izmu7Cd1zVWf6V/YUfluVHO0Xis X-Received: by 2002:a17:907:3e02:b0:782:1267:f2c8 with SMTP id hp2-20020a1709073e0200b007821267f2c8mr29455105ejc.585.1666647281975; Mon, 24 Oct 2022 14:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666647281; cv=none; d=google.com; s=arc-20160816; b=maaa3HCM1/qBGyDCLqwdbKboz9ONVWM2oOf6NAVQxyei+KJq3xe7khMSM/S9Z7jXmM Eil6oIAAWAWAGtz58GpzvX/j+i535DsQUDgoaKqdL6qNzcbkh/BC91+0LzhPcqnTfEg9 owBRwCSpV2vyRqojT574ztAzUj7VxktrUDp2PLRcU46P8HVWFN/02xlvTtk2Keg3pt+o 4lalhb/aJEMs7yIpcv4BC9V1KWM8WDc2h8MCQrZif7lNPbGdznuvbBAeA2NkeTTChfYl ICtVvWhqLz0Sn2NrSaIffrOOzmaj8AGMU0HdyV90Fxj+dhrz6uYZNmyPfzSOZzxZvT3i Ltzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=K2kGQ1uzzqA0xWymbFltF9V6/W7ChuSY3sWXqrXX9m8=; b=PFqhNLQgcxaYFvsoJ/ApuzCWnxROrCx1A0covYYU/b2L6fzSdn+8Gqu6tfDrFdFFkh iZO9G/dsZc0ImyP3yTeeZ5pwPC7PBFm3260TAb0wqwOk9Ci6P1fB57I2ndby4Y9pPlb0 1GyaKYRFg2aVar72LPd+gqRADp8aRccQj625/HS90Ymc7QWtz/W2fKSesB6Lg9WUFfxa f9X8yO/5JgkwxTnuQ8tlfBPQisBYRSdxEMfAFRTcDcBLwIulOxTv7TF32ZRaGSexKtnB rqcWfU4l9N3fSmRuzsEZqf7Z0auDLNQJII4aGZisXsAd1Edwm7p0Yed5W5qdJcPlMzFB gzJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=iCo9+oyt; 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=siemens.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a05640211c700b00461f7816e27si994958edw.490.2022.10.24.14.34.17; Mon, 24 Oct 2022 14:34:41 -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=@siemens.com header.s=fm1 header.b=iCo9+oyt; 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=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234124AbiJXVR4 (ORCPT + 99 others); Mon, 24 Oct 2022 17:17:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbiJXVRR (ORCPT ); Mon, 24 Oct 2022 17:17:17 -0400 X-Greylist: delayed 1889 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 24 Oct 2022 12:23:18 PDT Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 567852D2D5E for ; Mon, 24 Oct 2022 12:23:18 -0700 (PDT) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 20221024130239ff05e52880d9cf551f for ; Mon, 24 Oct 2022 15:02:39 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; bh=K2kGQ1uzzqA0xWymbFltF9V6/W7ChuSY3sWXqrXX9m8=; b=iCo9+oytoKkqsi8D6FE1CqIrKRjRBDp0s+x9g85W4BMGVfZAjDlMJCk0M8NCG3YgAXHg1Y UknYlfcxZN7zk9hKtLB/4hNCrwX4cPP/EiBlR3VHPSwIfGqZhCVy1Gh1lXj2/FAVOAvfCHVy ej/gR5+Z+wXC/8GDp9yPdAd/ojYU0=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v2 1/3] tty: n_gsm: introduce macro for minimal unit size Date: Mon, 24 Oct 2022 15:01:12 +0200 Message-Id: <20221024130114.2070-1-daniel.starke@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS 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 n_gsm has a minimal protocol overhead of 7 bytes. The current code already checks whether the configured MRU/MTU size is at least one byte more than this. Introduce the macro MIN_MTU to make this value more obvious. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) v1 -> v2: Incorporated review comments. Link: https://lore.kernel.org/all/fe537e8-7b2-61e2-767d-787b923c7456@linux.intel.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 5e516f5cac5a..570c40a3d78f 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -89,6 +89,7 @@ module_param(debug, int, 0600); */ #define MAX_MRU 1500 #define MAX_MTU 1500 +#define MIN_MTU (PROT_OVERHEAD + 1) /* SOF, ADDR, CTRL, LEN1, LEN2, ..., FCS, EOF */ #define PROT_OVERHEAD 7 #define GSM_NET_TX_TIMEOUT (HZ*10) @@ -2712,7 +2713,9 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c) if ((c->adaption != 1 && c->adaption != 2) || c->k) return -EOPNOTSUPP; /* Check the MRU/MTU range looks sane */ - if (c->mru > MAX_MRU || c->mtu > MAX_MTU || c->mru < 8 || c->mtu < 8) + if (c->mru < MIN_MTU || c->mtu < MIN_MTU) + return -EINVAL; + if (c->mru > MAX_MRU || c->mtu > MAX_MTU) return -EINVAL; if (c->n2 > 255) return -EINVAL; @@ -3296,7 +3299,7 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc) return -ENOMEM; } net->mtu = dlci->gsm->mtu; - net->min_mtu = 8; + net->min_mtu = MIN_MTU; net->max_mtu = dlci->gsm->mtu; mux_net = netdev_priv(net); mux_net->dlci = dlci; -- 2.34.1