From patchwork Mon Oct 24 11:31:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp640985wru; Mon, 24 Oct 2022 13:34:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TYsy0ibkZ25v0udpnBRuOhYgoPfwh/Idy3iruKgIhvJ5ld3ZxgzsRUH5kIdY56HSjgOug X-Received: by 2002:a17:902:e790:b0:183:88dd:1d30 with SMTP id cp16-20020a170902e79000b0018388dd1d30mr35294108plb.62.1666643646074; Mon, 24 Oct 2022 13:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643646; cv=none; d=google.com; s=arc-20160816; b=ERex7TBnkPOsBB98zWvH0d8N1B2RxhqAIs4RyJvXUtIevaun/2FpxGe7e3tLt74Ro2 c22e5tTL7Nx08oN9DbX6UttaqTSBY8dUUJuyXwURS1hCi7Aik7cANamd4YDBcTxFNPZb kPBM1Q/p8ttAIZZGIs4HWZ6L6H40+AKWtslfX11Og3+ApMKXLSsZkf8+Jd+pMVVAygmG 73pRNAlC6zSdlCoIQdyAbBl8hr306l03o11Q0NhiLeQPAQd1TeDHP0E5C8h8G8H0W7FZ TxKWfuubq1QkG1gFG/jD+b02QZNpc14zQHvs/a71Z/ZQwnJVpkT79PbT7ulSeM6S/EyF GuXA== 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=qSilnuQKh3wu48WyIcdpNKPyo8Rb/ADYjdccpCk+yoM=; b=fTt2HEjiW+3TbB4SZn8HCY6sEtFiMiN18qecS9pg5RSd5hel/U7UG2Z4pgTccVdCqK OVUFtgFtWw8/6BHnM9ySsMJYz8j4RaIHVm7ZNLMMnHlg6hBSLVKUq9y5mXhZQOXC9sf/ 4AM2Pl55wpGwYeBCqYkP0HkM8S1CLbS+MOk2+bb+XPRh4r/sNpGlXHtOBjn0AYwgBOWC MVEb33r/Du+a1pG8eTnaNLsJ004qYsgX2IcY6wwi33ccr9tgLoKhCuRHKa/4hTap0anZ 6ZlXqHHNzptk8h5fNeP9ygBKMhfzs8aWQZa7Z1ThBJPUWC3pHcfZAR7pPZyIwmBnWP4s vGlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TEbV9PUs; 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 s11-20020a056a00194b00b00563653bc151si737585pfk.110.2022.10.24.13.33.51; Mon, 24 Oct 2022 13:34:06 -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=TEbV9PUs; 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 S231584AbiJXUXn (ORCPT + 99 others); Mon, 24 Oct 2022 16:23:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234138AbiJXUWz (ORCPT ); Mon, 24 Oct 2022 16:22:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF4F28BBAA; Mon, 24 Oct 2022 11:38:29 -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 641A8B815F0; Mon, 24 Oct 2022 12:13:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 860E6C433B5; Mon, 24 Oct 2022 12:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613606; bh=LQ0m32+xLnc7SlLTPzhWZlsx030LdZRIcjFUrM6CNfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TEbV9PUsMp2XVd6w0GCllpGAN+z03lH2WBe7k3XiLBaVna3cS0mA7xSUX6pQFiWot jtnX4sgJX/TTRGWl/LEpI6rSjYtz5SDkK7oQxJb/Bbb3vb1j6acy5cVKHwSub1DMfA m7unnr/i1MSMNh6uSk1q7YX4e7jkTabQBK/0XySI= 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.4 201/255] can: bcm: check the result of can_send() in bcm_can_tx() Date: Mon, 24 Oct 2022 13:31:51 +0200 Message-Id: <20221024113009.694860245@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747602527821673824?= X-GMAIL-MSGID: =?utf-8?q?1747602527821673824?= 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 63d81147fb4e..fbf1143a56e1 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c @@ -276,6 +276,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) @@ -300,11 +301,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)