Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12452106rwl; Tue, 3 Jan 2023 14:51:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXseur/B/o90oxHHlUfz/g2MgKFSEC04AaSYabl8RJ+EpoawcHc/nrsejtuTQqxKT7F5Mv4R X-Received: by 2002:a17:902:ab4e:b0:186:fb8d:f4d3 with SMTP id ij14-20020a170902ab4e00b00186fb8df4d3mr50040602plb.5.1672786283127; Tue, 03 Jan 2023 14:51:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672786283; cv=none; d=google.com; s=arc-20160816; b=vx1X9W2PX0H363Ok7PRiBIiy78U/JiqiFwQxjjtCg3kv1/Q/yUyJSTQBf9TERv7ey5 jbVyeTKZ4alIgZt3D1jO4QUSF7RxpaRPV8FEURKJ6+vi2+JTkVjbE2A0ZeXI9qrIihHq kP2wIC4xtwf+t/aGcHDX2B0m+FMtI/yRzcx4n0uLbGjePm8hFnsn618zN34BeU5OGE5z U/+fqINT/rk3J/zKFdglQAjEWFqdfnKx7FhbJEx/3WVn/eCBt3366zKw3EVJDkY8Bs5r 21RT7umIn6WPEgIMYwEk9QDwZVpFFeS69Q4hEjbR+VF+rafJg4Yzc/gabeCd0Y5QWce2 hZKQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=nQsquKCgBcLgQieVOG04ot3VHyn1Sman9uwZ5WiSKhw=; b=VDYa2Kk+plIFdPCfADL263wvlIdaLXo8l+Haf9/BRGRDqMKUTF8NRCFYH59Or1Q39V zyv8mwXmcdBZJWtH+jkaG2m+ehn5yL6/YWdmzr6OMk051dRNG1cz29sBLC9nYVYQd3DI zD2QAEQjC3pJqV/cOM1RmRBI4xvv4nnX/r7YDtVEHVm4Dh0YBgCPJMejWEJVqkHxpiYw OcPbCzxtYgz1AhlWmKPHMSoZy3ELV9+hDrs4ShoJjZJXt7JYpfAEcr02Ur2tyfk0Umve SgkXQ0e9QpgLxhj2+rFBpA7ysUpKMuBUksZhyBGSlRPw/twTzgyzJdoqI8tRyhf9Dgwo oHhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=R6QGFxZj; 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=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d13-20020a170902aa8d00b00189444d216asi30276803plr.336.2023.01.03.14.51.15; Tue, 03 Jan 2023 14:51:23 -0800 (PST) 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=@ispras.ru header.s=default header.b=R6QGFxZj; 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=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233320AbjACWbW (ORCPT + 59 others); Tue, 3 Jan 2023 17:31:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238068AbjACWbL (ORCPT ); Tue, 3 Jan 2023 17:31:11 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 266C3E24; Tue, 3 Jan 2023 14:31:05 -0800 (PST) Received: from fedcomp.. (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id 86DEC419E9CB; Tue, 3 Jan 2023 22:31:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 86DEC419E9CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1672785062; bh=nQsquKCgBcLgQieVOG04ot3VHyn1Sman9uwZ5WiSKhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R6QGFxZjzbCS2e4JKCul3q4pTmnJIcqTxPs1u827cjvYkrwv89hXj7nHQY2VC6UWA QdHZYTU5XZ4ZgsBmaiJGwJRO7ZWv6hfvdF38PgAGeBGwj4sAGiza7zAKlOnBn4WKjO FiTxSWjlGL8wXovie2FeOc2VOcIvRheqT0p9cKJw= From: Fedor Pchelkin To: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , 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 Date: Wed, 4 Jan 2023 01:30:52 +0300 Message-Id: <20230103223052.303666-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <875ydn49h2.fsf@toke.dk> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-kernel@vger.kernel.org > 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. > 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.