Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1209384rwi; Thu, 3 Nov 2022 02:27:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+AuGrarb5AcgAnlMlgVv/VMCTmiIMpJgNUBfEjF9MSHcI2Q2yB6LaE0Cgnp1RVXVdF0ct X-Received: by 2002:a63:6c06:0:b0:46f:cd2d:2be4 with SMTP id h6-20020a636c06000000b0046fcd2d2be4mr15801225pgc.101.1667467678537; Thu, 03 Nov 2022 02:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667467678; cv=none; d=google.com; s=arc-20160816; b=F7cLljgd4j9Xie4z14L6UwQOo4fRuY399phHdHMzHL08uwI6mvmm/i83LvlfaIhS6f lix/ANZ9BN1/SmebH7m000v/7SGayb2ajZKQPVoE9G+qK6SNs9/XUp34Cg1OMH7InR2Q IZDn8PNil8qyp6S6d8Q4TimB32uCJT2AkE6L4luCN8T7TxsvtWy/hFvdxFyxUFDaNk4P XMapUdr3T+VpiyFH98DuXPr5u+elu6FyzUr+5FJTlQbJWQxMDuNNf2pZ8AK8xdiUatSU xT5jZpIOj2T6dSHI1gCsuH4EakdTd7LVH6o2uH0H8Z0nEFSANlTe2pnwM09h7dh/3UFr wNOQ== 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=ymHU3X/qr6+q1iY2LysQF2vzhHX/JM5cmkF/ZciRuKw=; b=RmpiquyXlhJEYtU+RYEEz5QEhvAH5B3UO1BW8aA2TFhdTCKfBzaSov25DXzN367sHF GZ/LSmw4QKHFpLJcVO2PC+i0EWoe+tL6rBNQbblN1SPDPssORl+opueipadqrQU/j2Zp Ygh3lePaUML7abmMMP1woz3MQWNWlf9PD5u+poBMpCwY6vTbBpBpP2ptUtLDhwrVN+WC Z1fMfmLfSaahmLbddRlLGDuJsz9d3hII8FLez5V++Ksgql2c0YlbGlHimhXuZdQinWoc CZbUfdiWi8CrsBRHm2W5TFkm/AwTj/2sM+lpb/lGPA64gnt7XBC4ZoLPw07uErb40kGn g3uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=m3Y1LgnT; 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 t19-20020a1709028c9300b0017a0e7aaf6bsi153014plo.128.2022.11.03.02.27.44; Thu, 03 Nov 2022 02:27:58 -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=m3Y1LgnT; 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 S229788AbiKCJVz (ORCPT + 97 others); Thu, 3 Nov 2022 05:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbiKCJVS (ORCPT ); Thu, 3 Nov 2022 05:21:18 -0400 X-Greylist: delayed 63 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 03 Nov 2022 02:21:15 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 30062DEAD for ; Thu, 3 Nov 2022 02:21:15 -0700 (PDT) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 2022110309200924e90a3c9e57b9dbd6 for ; Thu, 03 Nov 2022 10:20:10 +0100 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=ymHU3X/qr6+q1iY2LysQF2vzhHX/JM5cmkF/ZciRuKw=; b=m3Y1LgnTK9GD/M6e5Eesa6/4c5nbgngUeunmNE09fE8Jngw2IcNfHQOIwiOQjzdM+DF0Q/ oWKAxlzd5ix83MOzbIGM18o4xWGek2qQp6GXbS5y5DBPuXB1mP5T/Pey+OH7RCxWCy2aVoUj +GACObHy4uk5QZ0zWvqC8kmm+Hwjc=; 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 v3 1/3] tty: n_gsm: introduce macro for minimal unit size Date: Thu, 3 Nov 2022 10:17:41 +0100 Message-Id: <20221103091743.2119-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(-) v2 -> v3: No changes. Link: https://lore.kernel.org/all/20221024130114.2070-1-daniel.starke@siemens.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