From patchwork Sat Oct 22 07:27:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1120816wrr; Sat, 22 Oct 2022 02:26:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6c2ml9utgXk3cDEjuSx33RvhhitozvhkKPiJyhUDRsdtCJIULx8+pivDX/xuyq2k0BJYn+ X-Received: by 2002:aa7:818f:0:b0:562:dc99:8a84 with SMTP id g15-20020aa7818f000000b00562dc998a84mr23384699pfi.30.1666430795180; Sat, 22 Oct 2022 02:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666430795; cv=none; d=google.com; s=arc-20160816; b=A0RofHy/nCJoQMOvweV8hJS/bKsk4biTyVzhaadUdv0we/QiUAwHL3e17z/8fFeUzy 8s59b3YgehEKQtl0gOhXCxSoC/8PIsLcXoSJYHKr2XzXoudTGMALXFuZ/kmVvj9qQd0E Ibxa0DcUe0+Uj0hjRxy+Z8LuVEU+u/LMygXkd7w6A9HnAmskLilrXfCZJ4zptN3fKb1k Ivp4ooXnkbZm8RkhCmKQBrpV4cC4MNGfJMitZdqEX3NNUyFGpB7Vh5617NLj7pd7mE1/ hZHB1yaRMsqvHbJj4W8KDsk8VlfoqzGJoF3hxBsi5VyA7DgGraPf6PJGPKU+02nhddNb rpVQ== 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=Bvop/fiX8oo9wmbXwfDKLsyD0kIhNNKOKZW1TjHzQEc=; b=mDIGiVMOwew8BtkcEBFDwLmEq6GtCL298WJZF+ygz4Ih/D1PW4YV5EzURQdGU1VTLH 8XBju0jGSYlnGNGsyJX1yOl8B/Gb5Z9ygJIfznOhSni6GT4CsEU5vOBlcLOixV52hxqh i6ePhJEzuqY30larlQOuP41xPoHx+n3e+3l4nM8ZN+sFTOh0YJg3zFQHW2CjIvHO87q0 19909sqU8Jx0+/dUgwCjHnUg+5wbn4seOUURvBagyibGo/RYuCZCm52VqTIXsMR/GIQw I3WXdr/LufaBzAmR2049EGpbQgzzElP5A1WUYfWX4SsqrYRrVYn/i1ofRIZoL232Q9R3 3uDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="CL9yz/dY"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a170902748a00b001865c55049dsi9771322pll.570.2022.10.22.02.26.22; Sat, 22 Oct 2022 02:26:35 -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="CL9yz/dY"; 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 S230218AbiJVJDf (ORCPT + 99 others); Sat, 22 Oct 2022 05:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235092AbiJVJCr (ORCPT ); Sat, 22 Oct 2022 05:02:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F7D12F7C34; Sat, 22 Oct 2022 01:17:46 -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 B9CDDB82E18; Sat, 22 Oct 2022 08:01:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32E5AC433C1; Sat, 22 Oct 2022 08:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425698; bh=Cq0O6Lq0YGpcmM8L/xBbBUGYACre6Ya9iOwxDcgfiwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CL9yz/dYuHvfbmrfpu7e3/o0qO/RbMJ8UMf08Y0zP2qqFADmE5ivH/1oA9wqKSzmH Q3kMgyb32cnsrCgTJ6lo3U0TsKlfpND0NowwZGdHURoGxN7XoRgkuTMRPyIE6+MTjP uEhp1DWBWvwQscHpsLEdw5ASZ1KQuPR/YnYZXXdE= 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 5.19 585/717] can: bcm: check the result of can_send() in bcm_can_tx() Date: Sat, 22 Oct 2022 09:27:44 +0200 Message-Id: <20221022072524.309647985@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747379337447923440?= X-GMAIL-MSGID: =?utf-8?q?1747379337447923440?= 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 e60161bec850..f16271a7ae2e 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)