Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp950665pxp; Wed, 16 Mar 2022 22:23:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoJNzXedaEgL5HMgx05q00fpz8t7dhU8bYvkHrgagEUOgtSCSDSStu9vSgnmsV9PZSkHOF X-Received: by 2002:a17:90a:c70f:b0:1bf:3e2d:6cfa with SMTP id o15-20020a17090ac70f00b001bf3e2d6cfamr3360456pjt.70.1647494604074; Wed, 16 Mar 2022 22:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647494604; cv=none; d=google.com; s=arc-20160816; b=lR/b+Ow2FSgX+oOaT5qzYKCzUSEAd4aDyy08Rzd+LWQHSP1P9gpByyeX1G5ODhTd9k uZeH3M8yRRxLP7Dz41OZCOo/GkTmRaW2OiPLquPg51/sMWLBW/NJJaxxu6uZyOI4GbHu /axJicMsUNRKQ0VQW0mq9jhDICvOcmvrix5YMkAlypZ/VN3GKh3nvmzMvT03tDnvaJzt 8ywRjPJAWwaE/DdGkEPwwb6bvY++SAiYH4e+jkOt1v89qm/GZIF0XvFHyq6GXuZWYcTs z0PBQoCt5BdqE/6zBJOosTkCaKIN6gGJGHLh2WDe/1LC3z92JXAKaawQr9va64A8nyZr Abnw== 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; bh=Wa8W+5HohqlCmTbDLHwTOyflzeNzbgTr3Yvad48d8DA=; b=omZAqyKKFKewNguTfbRQf/33lLRKNvnA6zxJhUdZ5yKzi7g0mw6J/k9exzDtkiuAoo QKPqc+dikczHGRuscqV+bZeNCFL8jD4oXD3Qy+galPNuAXDDSVTw/JSOO67ITY//q5Tz ffYJ3szWjO3QOrZn8OlQvFh5IX7TrGq2VVcXrQ7xkEL/ayDlfBBtrZevkeryPrcTAqzp CQWqLwUJbsrmJFCN3lLU25lhHi3aR4gaOk470aHVLGbj8CaECD1F+pPrucjGLQ6ge+o+ 5GCvfSrhkfmj0kQbg6I+DXY880cQdyZFwY6uD0cKykzVXHxLp2FJ2yj8bStBlCc/uF8Q vojQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y21-20020aa78055000000b004f0f18cdccbsi3375431pfm.319.2022.03.16.22.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:23:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 24DDE223BDE; Wed, 16 Mar 2022 21:29:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345638AbiCOHuc (ORCPT + 99 others); Tue, 15 Mar 2022 03:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345634AbiCOHua (ORCPT ); Tue, 15 Mar 2022 03:50:30 -0400 Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 893F512ACD for ; Tue, 15 Mar 2022 00:49:15 -0700 (PDT) X-QQ-mid: bizesmtp66t1647330538t2e5fnkr Received: from localhost.localdomain ( [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 15 Mar 2022 15:48:52 +0800 (CST) X-QQ-SSF: 01400000002000D0H000B00A0000000 X-QQ-FEAT: 2/V7nd32TUNNL9VZeRdmamHW/40ftL9nCkS+SA2Cjt/VReeEKtayf5eld+pEV S4ppc/UoEjWTLGfmglppM+tlrceAEQKUT8GYjsIS12xW8iba2jYmD1uiIvf192fiOtMtPEC YmvtbesERPpeWv/c+7il+ErWeI48CQ29Id0af1WL2j9uc8X4IS1SNQ4eQW+LGYHNqnEdBIA w04yePwuzg+XufdJPMJS7dni4c7k8ALBFJDuUZN8k8+PZvjhjbXtDvoQn6aWeSwpWL8KBVn Tz8S5IFOUZo8TDYAA08sE/IXH+t65ZqrvyXWTf22Q4k8Es8qEE61J1HI+7HD7hOVez3lPJu jryYjzT43Ney0ju5jnA02tpZErfIx0ha3o6OKCP X-QQ-GoodBg: 2 From: Meng Tang To: t.sailer@alumni.ethz.ch, davem@davemloft.net, kuba@kernel.org Cc: linux-hams@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Meng Tang Subject: [PATCH] hamradio: Fix wrong assignment of 'bbc->cfg.loopback' Date: Tue, 15 Mar 2022 15:48:51 +0800 Message-Id: <20220315074851.6456-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 In file hamradio/baycom_epp.c, the baycom_setmode interface, there is a problem with improper use of strstr. Suppose that when modestr="noloopback", both conditions which are 'strstr(modestr,"noloopback")' and 'strstr(modestr,"loopback")' will be true(not NULL), this lead the bc->cfg.loopback variable will be first assigned to 0, and then reassigned to 1. This will cause 'bc->cfg.loopback = 0' will never take effect. That obviously violates the logic of the code, so adjust the order of their execution to solve the problem. Signed-off-by: Meng Tang --- drivers/net/hamradio/baycom_epp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index a03d0b474641..36e6de42ae77 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c @@ -982,10 +982,10 @@ static int baycom_setmode(struct baycom_state *bc, const char *modestr) bc->cfg.extmodem = 0; if (strstr(modestr,"extmodem")) bc->cfg.extmodem = 1; - if (strstr(modestr,"noloopback")) - bc->cfg.loopback = 0; if (strstr(modestr,"loopback")) bc->cfg.loopback = 1; + if (strstr(modestr, "noloopback")) + bc->cfg.loopback = 0; if ((cp = strstr(modestr,"fclk="))) { bc->cfg.fclk = simple_strtoul(cp+5, NULL, 0); if (bc->cfg.fclk < 1000000) -- 2.20.1