Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp209803rwn; Wed, 14 Sep 2022 19:11:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR7EolTuDFuqPwEKTIQe4sUP43EXXSs6ubWz2wpzltt7oC++4w04BNqiNMMscuWX3ILXhD88 X-Received: by 2002:a17:906:4bd3:b0:731:3bdf:b95c with SMTP id x19-20020a1709064bd300b007313bdfb95cmr27941332ejv.677.1663207917942; Wed, 14 Sep 2022 19:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663207917; cv=none; d=google.com; s=arc-20160816; b=emOSKehRBSlOoNb5GMTTj0iiNkyAPj7/gHsw+rId5aS3VFlJI/z2EErgTQvDVBAd8w RAiyPhXMCPYMSzEpgwTFQMhLR+wK+TW+A+16rO47ax5aYoWo26yW0XnisSTepGFqSQZG +Qi25SUBVH5jkXc65R30xarKxa+907zO3SWxN/WGGZxYLR6B/vLt3IhRzA3PAu56UEg0 n2M6/WBP08iz5GdqIwCGzcfkgB/PYRn1tr1KgicCbwe8msi62QfhgbxMYq9cHWCy86z8 cnTNKVaAypMsOI6tBU5DYmO8ri6lSbD/30EWBJWXhoAlbgsOp6+3gVp3ZziCmGrRMR3l 6goQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uwJ3TQZSPTLRznAoPDopC0VpO4Vl+v6X1JP7ATPwWK8=; b=MIXwSFJ41JmWi+O3HBzHZrjyE6lh+biGwStMY+ET2ZUWvFtlbTLLR/Bji1Rpl2ZZu/ c/UECARQVzgD6gZUUUgQ206wt1gBUsLgM5rM0ov6jIwQxDyeNybwYSLraMZbNplEEN7L CneBQnsJBTwkHkb3ISGMF6KHi8iWTYha68gPGtZ67Q41LEpvqVJWbOo3Q6rks81lZK/M DYP+0pOcmdxSyY6X6nb/uPajhECIpygFQjTmC8V+v6tESomHvbhwPpkrLET6R9QY/s7c y6sFtTTmfU/lDr4u+hNOwM8S2m3lIgwQPByOT2Mx5qQpV9+XogJWY0Sw3yK3S//wTC+9 6Mvg== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp39-20020a1709073e2700b0077fadd74307si4937412ejc.128.2022.09.14.19.11.32; Wed, 14 Sep 2022 19:11:57 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbiIOB4P (ORCPT + 99 others); Wed, 14 Sep 2022 21:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbiIOB4E (ORCPT ); Wed, 14 Sep 2022 21:56:04 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA1148E4F3; Wed, 14 Sep 2022 18:56:03 -0700 (PDT) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MSgDg60jHz14Qb2; Thu, 15 Sep 2022 09:52:03 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 15 Sep 2022 09:56:01 +0800 From: Ziyang Xuan To: , , , , , CC: Subject: [PATCH v2 2/2] can: bcm: check the result of can_send() in bcm_can_tx() Date: Thu, 15 Sep 2022 09:55:56 +0800 Message-ID: <9851878e74d6d37aee2f1ee76d68361a46f89458.1663206163.git.william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 If can_send() fail, it should not update frames_abs counter in bcm_can_tx(). Add the result check for can_send() in bcm_can_tx(). Suggested-by: Marc Kleine-Budde Suggested-by: Oliver Hartkopp Signed-off-by: Ziyang Xuan --- net/can/bcm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/can/bcm.c b/net/can/bcm.c index e2783156bfd1..a571c8d4338b 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c @@ -274,6 +274,7 @@ static void bcm_can_tx(struct bcm_op *op) struct sk_buff *skb; struct net_device *dev; struct canfd_frame *cf = op->frames + op->cfsiz * op->currframe; + int err; /* no target device? => exit */ if (!op->ifindex) @@ -298,11 +299,11 @@ static void bcm_can_tx(struct bcm_op *op) /* send with loopback */ skb->dev = dev; can_skb_set_owner(skb, op->sk); - can_send(skb, 1); + err = can_send(skb, 1); + if (!err) + op->frames_abs++; - /* update statistics */ op->currframe++; - op->frames_abs++; /* reached last frame? */ if (op->currframe >= op->nframes) -- 2.25.1