From patchwork Mon Oct 24 11:32:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp480867wru; Mon, 24 Oct 2022 07:21:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+hsunFcKssOzC368vPoosVjc26fBQDgE2qmeBfCZ+DgOry6jojUaVY3hvl4lCyorx1kXH X-Received: by 2002:a17:907:2d06:b0:78d:50db:130e with SMTP id gs6-20020a1709072d0600b0078d50db130emr27689762ejc.371.1666621314864; Mon, 24 Oct 2022 07:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621314; cv=none; d=google.com; s=arc-20160816; b=dO63r7DIjFsfhaxo6knEUSr1jKcucKhndb/CFmtL+uLWN8RPK9Z/5DpfhU8zoi+J2Q FcdfQ5PcranuZHjEKdYsIRNuxHn9n2bXgBstIXOx1RVm9GeAacDFJMoHdcZrkd1j5lpA i+BKwgf5qgkX2p+rh2B16AZeBK3iqU7ZawNi6d2VmlDs1MIDYnFzX4MW1dgSrA9IbD9O upy7CxyAhCZuQJ46hYVD5r2qSM5jJarH2ABglOgFzLmY2+ucWMI0BfmcMYe53XU1q4VO RLq3G1/+hDm/rFUKsJDyJ5KdylIESZc84NXMtuZ+gY5CbivqLlS32KfImzfse3V7EEap Qy7w== 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=XO1gmSZJUIN7xacbkvJVQ6VEwkgz/xpS6qtnbmslMnY=; b=d56AA9lhqFtVy+tbwnJg2Lepu+i0tIFxR6/45J07QGc0pbHV7/P1u5YJ5WK4gKnKUs iXGgyIZlQ+B5hmXKxbk0+5Lk+5TTu/P9Xh1KjTd2tgz4sb9ruxOWMn+nZRJ2UpdHIyoB 8CtDB6CHKEgGuIY0Fkiwm1xpX8Ba1FM5CfDoowkezhDB/EW6gm44qe3ad7b+Z0t9S9si Kt8s6pHgo2gQgFam8sokCfXxxZ0sRFj/Frj097afcxrDO19+8w5qHltCQLbaKd+7OPPA h+Otrk14oH5NzfSP7c7VZxSCJJm+cYHqrJ6IdxKHHIb6qB7zO0EY+XZ7EPAXU5jD43nd zYhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nDgJk1EF; 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 t30-20020a056402241e00b0046069e4590bsi12491749eda.104.2022.10.24.07.21.22; Mon, 24 Oct 2022 07:21:54 -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=nDgJk1EF; 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 S233172AbiJXOUA (ORCPT + 99 others); Mon, 24 Oct 2022 10:20:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235602AbiJXOOy (ORCPT ); Mon, 24 Oct 2022 10:14:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F90D20351; Mon, 24 Oct 2022 05:54:54 -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 dfw.source.kernel.org (Postfix) with ESMTPS id CD97E61358; Mon, 24 Oct 2022 12:53:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFC40C433C1; Mon, 24 Oct 2022 12:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666616000; bh=e8Ik+29A2+LveAsDTMpl0Ms9lWA6REu/LzsXssYotTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nDgJk1EFTYJbQpSub4vMDUm0oW4Si1/ivGpL3ymQraxbD5J44ZgTxmpMDsXJSkihc 3+Fr4rpml8srp5UzldAL5Mn6RHaEAOZd1lK3oVQCwMGBekCugaXBBt6kuXHsBJ0tFX yGkfeVJ8NNUC4x2vU0s+MJtcFOsRItTbduQGdLAM= 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.15 433/530] can: bcm: check the result of can_send() in bcm_can_tx() Date: Mon, 24 Oct 2022 13:32:57 +0200 Message-Id: <20221024113104.690990338@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747579111892898916?= X-GMAIL-MSGID: =?utf-8?q?1747579111892898916?= 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 e5ffd2bd62ab..aab3a18f4a90 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)