From patchwork Mon Oct 24 11:31:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp422451wru; Mon, 24 Oct 2022 05:22:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7PuknPI5KJeNwyWlbPG/ySYZvuwNvx0dmYTUOcT6JMTe0yzA6271u4Ej80UQMQSoTSRHVs X-Received: by 2002:a17:907:3f96:b0:7ab:34aa:9094 with SMTP id hr22-20020a1709073f9600b007ab34aa9094mr111639ejc.85.1666614163718; Mon, 24 Oct 2022 05:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614163; cv=none; d=google.com; s=arc-20160816; b=mEu4lzvZXcvK492q0ZcrV6FxzgAMZLnMsCeunY8nhkIS5LB0yWiKqfgSAtlQqlzcLd 0KMr8zPtSXqEUNe4VQJAgzthcGpMfE97puxQin0kIwltxH0megcykNvsx7ErfV5TqCRz RHlb0xUyL37FUE5G8KO/PfcYt0B0m+4NuhuUQON0kidDJRpRrREQiW7gujKeTfybc1wJ PXUuqNI15DoxDNL9yDEOqSBN4lB9VDzga4EWUQHI50082ImJKxS9LB7yqM0neUWyb8Qa 6t0G1kWLMGQ7HzOC3Ri/yb/9MocIMkexCd7rgxtAlWWiHIo5d7nXUclQz8aKcKO7Eux2 co8A== 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=rkDWj4WcO0BpgN7NQzjQ82CmB/EHfFEqCMmRkbTngzU=; b=yuru68BSX+oHiMbJDgsU8lXTw0SyzrMFXaGbnK1WCIGbuO2y1c36f0YEdZWNo8z4UF LpjRgFuPxTQWRtO8gcRiHfwhTyWczFOsAPl0zaQCwWFPICqO0m+o8Wk8iOhb4t2YMwLp wvR6X0rUUOG6YhzXx2OI3UCrIaPcHGPC4xZkklmA3mHIffuF3L2FVtZeMzRrRMrG5qia E0fLIX8GibPaBq+J+e7j+AxoQwBL4MsKuTeTKFyiNksNIiuGOBVCKeqWYvNhEJSH+G8r sArMeNcquGh/kUdl/lIhnvOnxKvjpoyjnbi+EZEKGYTasaCJ93zQhkgrp7yVxRcvIMYM Ieqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TutMja1F; 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 jz4-20020a170906bb0400b0078dd73ae297si24670864ejb.172.2022.10.24.05.22.19; Mon, 24 Oct 2022 05:22:43 -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=TutMja1F; 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 S233279AbiJXMVG (ORCPT + 99 others); Mon, 24 Oct 2022 08:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233404AbiJXMTW (ORCPT ); Mon, 24 Oct 2022 08:19:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AED982775; Mon, 24 Oct 2022 04:58:01 -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 6E574612A0; Mon, 24 Oct 2022 11:44:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81B20C433C1; Mon, 24 Oct 2022 11:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611846; bh=ZM8KwLzQMU6Z+0eJcv/Gy/7anpAdhPECPWXhIWxPZPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TutMja1FKraUaEqw/6lgjY1zVXghJvHmZJaxEMlh6zC6xAqMooETO8iR8+vArGAJY FZkchDehEsI+Cnba2s1JQhxKejua0J4t78zrI/CUqx0MTqnxH73oiRVjwnC8SaA5tW 9wE7NC6tirggYfTd9kIIjJD9hm+AwJXfq3xxShaE= 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.9 133/159] can: bcm: check the result of can_send() in bcm_can_tx() Date: Mon, 24 Oct 2022 13:31:27 +0200 Message-Id: <20221024112954.335214620@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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?1747571613551211271?= X-GMAIL-MSGID: =?utf-8?q?1747571613551211271?= 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 bfb507223468..ece04ad50348 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c @@ -285,6 +285,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) @@ -309,11 +310,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)