Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12496955rwl; Tue, 3 Jan 2023 15:38:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXuK7YGUK7nSz25RdNLyEsgUTYNz+OOYsmG66ZjMHt5rZ4OroIsMhvxqd1BJBnlASoaLrFNE X-Received: by 2002:a05:6a20:d807:b0:a8:79bc:dfae with SMTP id iv7-20020a056a20d80700b000a879bcdfaemr57687061pzb.20.1672789136723; Tue, 03 Jan 2023 15:38:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672789136; cv=none; d=google.com; s=arc-20160816; b=TQOvx04CjuoF9dsROS5+/TBjYFkFHMHapfvYMWA1N95H4n8MSjNu/eZG5hlcfwNR8c 4ncblGd/8UKNMEJ0UqVS6OeAcr18wVRE3gTl0c7J0y6uiIoC0taSn7KBYt4+JueGnsO4 uYwnbmk4vCU4Ws/t25Ok97OXO5CWP4lKmlIOBAy+EZFnXDm+z/HHbTxdM11/Blo+p9vP t2Bpn5Zn9XrAzQu1wk8KGWzZ0s4PonvsxHZ2F/aqrY1h3GlDi+LWStLDujlaC3ERY/zi WMUxdbVPHyju98weIe0LPj8nLc85WvvlaA8zE9natnvdax+yRLikwyo5Ahs5d4+f697S rW7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:from; bh=ynOWW3LgPvjCduGH9UcbEQT2h4nu+eDS7sALdUj0jpY=; b=p9Vld6n9HX5qKYD5cZBvRLW28JlR3kyX0Vq0tBzqmwCjk7APP/LGNNwUxhnOXPQRNP s6K04GYxvr6NHXYJNjevMGBzuNGRf4YRrgpweAiQ8O60v3XLv69Ak48cQ7UsjmdbUe6V GCMx+6IzCj6WwEa75H77JGm65FgA8jQoAd5QC2tLPpJo8ga2yjAxixPcz44ISA2MK+id 6PRR6Z8reH5zuzCuakLNDFcmQi9SsHAav/zg9s6SwAWm+cc/LmcGmGeKSzUYgAMDeSE+ /msYoV84QwkKN1S8ES6UxbrVLb7f+namJ41qjh5AjBUZnG70v1ylrKlvS1PppI+AUwJr Te9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=D8OcQedR; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=toke.dk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a631941000000b00477810a445asi32286160pgz.589.2023.01.03.15.38.48; Tue, 03 Jan 2023 15:38:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-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=@toke.dk header.s=20161023 header.b=D8OcQedR; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=toke.dk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233734AbjACXir (ORCPT + 67 others); Tue, 3 Jan 2023 18:38:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjACXiq (ORCPT ); Tue, 3 Jan 2023 18:38:46 -0500 Received: from mail.toke.dk (mail.toke.dk [45.145.95.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37F3A1DE; Tue, 3 Jan 2023 15:38:44 -0800 (PST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1672789123; bh=ynOWW3LgPvjCduGH9UcbEQT2h4nu+eDS7sALdUj0jpY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=D8OcQedRKM45liJhzV0Gsvc5J21BGX3cCKwbp0W1Z3Pcf4G0/WaKzIJC1P/gbXrvI FUBeWWB2a+PiWWV9SRxRNNm5AAY3G6ZKKTcYtrDDy6deDufpCTZ+17HGyBdHthZ/gt l1P1B0zw5K/9wRjYjGWCrJ9yJr3tXRQXFCVvUxEkhmHVXJ7+gEx/wzsxz1uYpZTqPU IXbVmvacTjuMt8TOvKKlSVIbzhuEqmUN2u4PWhqVjgumjKZpugEb95qlpu/JxBU9mc qAfz4vD6463ACL1hUzo5bDa8kQy+Rr4/VuCIOdTb+POWYnG+atjhVkK+G63lxCWJ0u SSa3pjuKoTskA== To: Fedor Pchelkin , Kalle Valo Cc: Fedor Pchelkin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zekun Shen , Joe Perches , "John W. Linville" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: Re: [PATCH v2] wifi: ath9k: hif_usb: clean up skbs if ath9k_hif_usb_rx_stream() fails In-Reply-To: <20230103223052.303666-1-pchelkin@ispras.ru> References: <20230103223052.303666-1-pchelkin@ispras.ru> Date: Wed, 04 Jan 2023 00:38:42 +0100 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <87tu172np9.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-wireless@vger.kernel.org Fedor Pchelkin writes: >> Hmm, so in the other error cases (if SKB allocation fails), we just >> 'goto err' and call the receive handler for the packets already in >> skb_pool. Why can't we do the same here? > > If SKB allocation fails, then the packets already in skb_pool should be > processed by htc rx handler, yes. About the other two cases: if pkt_tag or > pkt_len is invalid, then the whole SKB is considered invalid and dropped. > That is what the statistics macros tell. So I think we should not process > packets from skb_pool which are associated with a dropped SKB. And so just > free them instead. Hmm, okay, but if we're counting packets, your patch is not incrementing any drop counters for the extra SKBs it's dropping either? They would previously have been counted as 'RX_STAT_INC(hif_dev, skb_allocated)', so shouldn't they now be counted as 'skb_dropped' as well? The single counter increase inside the err if statements refers to the skb that's the function parameter (which AFAICT is a different kind of skb than the ones being allocated and processed in that loop? it's being split into chunks or?). >> Also, I think there's another bug in that function, which this change >> will make worse? Specifically, in the start of that function, >> hif_dev->remain_skb is moved to skb_pool[0], but not cleared from >> hif_dev itself. So if we then hit the invalid check and free it, the >> next time the function is called, we'll get the same remain_skb pointer, >> which has now been freed. > > Sorry, I missed that somehow. > Moving 'hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE;' after > "ath9k_htc: RX memory allocation error\n" error path should be done, too. > hif_dev->rx_remain_len is zeroed after remain_skb processing, so we cannot > reference hif_dev->remain_skb unless we explicitly allocate successfully a > new one (making rx_remain_len non zero). > >> So I think we'll need to clear out hif_dev->remain_skb after moving it >> to skb_pool. Care to add that as well? > > Yes, this must be done. I'll add it to patch v3. OK, cool!