Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6820546rwi; Mon, 24 Oct 2022 06:33:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6waZtw7+fr91w+7DIMJ1h65fptSJzGSPX/7xdW1sNj7pqoU32xVVHln33VdWFSIt9WhEtp X-Received: by 2002:a17:907:9717:b0:78d:9fb4:16dd with SMTP id jg23-20020a170907971700b0078d9fb416ddmr28327599ejc.720.1666618402541; Mon, 24 Oct 2022 06:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618402; cv=none; d=google.com; s=arc-20160816; b=0vAkcC/x3QEJblzC7VXAfvk+783HfhNyDGHXfyr3RdBRi561LNTXxxV0Oj4C2DHn2X kWs3SB9efrQlfvNG7FHaAusc7y54kyOYDeF3vYz/MMaFH6r3GaCqCeXjWT9sXj8v5jQG qwjFqHsP4erBPJ6ojQyAwvPrWjEPZCEHPYEZbEaagOiiGzE4eHSyrAgLvDCA+donLCR7 4QbvcHObVCYn/e7lTa1J/lO/Bf343Qf2x3k6O4ukmdYxTMcM8WlrsdRLNVqyd4YIelG5 5/m1b66zhWtgIVg1n8sTQdKpghASz7YM0cOyYlHwb0osqQPUZD20Jlk7hyLnT+f+zfgr cRpw== 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=PjSCLg5zsHyXPlnuRsaTGxznV2I2PlM89V5YYg/7h4Y=; b=RpIeEEf+Z4Ls0cKwzxwVVVbOEW/S7Bt5eC/XS1oR5GW3l3QTYPapUKo19/SJmaGBA5 YKWjWls/hC3d7mlULhF5nqnX8wAkzm4rj7TxtrFoR8DVXo4ekjCodZqXzT6Ips3TWgtB 32iNDvt3Uz8J9hbt7WDrynuJq18m+x32kf1LPrNt/Z9TqnQ577M/T6/ctyYa/ifctBNA oCZ2VzlIOCWvMHyDBnKu49RloNHTiIZqFEBl3i1meMXXX2n3rjWWGFHYF8T8fSEGLzY5 JCel6jVyx6cmhMTW8PrswWUUWFHPEs1o1N1yYw9YF7Rzp42GNp4uw+Zc9NBGJXgOvjOa coBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q9nKZmr1; 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 ka3-20020a170907990300b0078db376206esi21680212ejc.783.2022.10.24.06.32.56; Mon, 24 Oct 2022 06:33:22 -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=q9nKZmr1; 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 S231244AbiJXMkp (ORCPT + 99 others); Mon, 24 Oct 2022 08:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232012AbiJXMgq (ORCPT ); Mon, 24 Oct 2022 08:36:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3D288982C; Mon, 24 Oct 2022 05:06:10 -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 ams.source.kernel.org (Postfix) with ESMTPS id CEB98B811C0; Mon, 24 Oct 2022 12:03:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39967C433D6; Mon, 24 Oct 2022 12:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613006; bh=Kzis1vLhezwehNxVB+MAMkeHuzcWMxACM/LeTgmHF4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q9nKZmr1BlrXFhLC9us8I+JsMl31x0b8DGn5b46wnRnOAYQbLvGFU50Q6/lzf+aq0 tobXf4lRVCvmNPGjz0XErnezM9BeHe+kAxL8zqA6jdSn2M1OEzXWvKtpUncIBPSxtU s51SksCwiw1PfjnAsLgEJ7RViKU0/imN6O7+2HKA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Kleine-Budde , Oliver Hartkopp , Ziyang Xuan , Sasha Levin Subject: [PATCH 4.19 185/229] can: bcm: check the result of can_send() in bcm_can_tx() Date: Mon, 24 Oct 2022 13:31:44 +0200 Message-Id: <20221024113005.097019844@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 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 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: Ziyang Xuan [ Upstream commit 3fd7bfd28cfd68ae80a2fe92ea1615722cc2ee6e ] 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 Link: https://lore.kernel.org/all/9851878e74d6d37aee2f1ee76d68361a46f89458.1663206163.git.william.xuanziyang@huawei.com Acked-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- 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 3c825b158fb5..74e555a22de7 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c @@ -273,6 +273,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) @@ -297,11 +298,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.35.1