Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp6554rwe; Wed, 24 Aug 2022 14:59:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR7URmx3caaM5Ot7Od+Cun5xAYvnuTl4ZDQhZvkXAPaSJ89JBqG/3f88pUhU4Cf3F+tKeS4v X-Received: by 2002:a17:907:724d:b0:731:8022:94e9 with SMTP id ds13-20020a170907724d00b00731802294e9mr627953ejc.172.1661378360956; Wed, 24 Aug 2022 14:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661378360; cv=none; d=google.com; s=arc-20160816; b=jRcqsOvB2LIKCkLt/jxjkSx7HLees7LZyIBzlv38WZPslz1OqTnl9/0w8ITc99ym6d eEA3nKtqt9RH4wpen483+8650KlsBTLw/fWnMKWyo/z8MFgoT0CVb+7TiRkYeMOF6Bvs R88Rbz9IOK243Rql0f8VOTfW+kzhcbbr437N0/KWl0DqFSz8FLqIhxvmHCHqgCoXuYMI ttYUmwZ1nT5y0Ghb1LIAplqr3g/LLqn35UKFoj2FThiAELoeUSTNBLlcTW1ku4YLX6UP HkMmBpGqgQmCVgaByRLY+0wKhChsNCoiurAf1zIghmkqjivK6UMa1gPWNrhHjz/vEGg1 Gx1A== 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:to:from :dkim-signature; bh=jwWpS/IEJkDxPHdX0InnvrmEPux1NMA8vD9SgE2jV9I=; b=gP6qNlmqPgKMVfzLWTpiMXYKTEU/IydB00sj8un0/Zn9wS1dSve7RQ7J/rbPL0ZAAO f1n2VZG9ArLC+VtTySlgBeAucViRMTKqYtgXOlah0FBKxbbD2jl3gKIxs+eQsa3Fqm3R mzTnp/9pjq0HlQFVTpceiDD3QMQDtOVgPXgoFKvdXxL06sjWJArM75mgMHqExCnEP1da UCQ/Kv66+8l914lfkYdC6DyuD5lWuwTJZyAbvjUuQRcEA2DF0u6y5mQB0knLcQ791rKp sDbdyZmF2YutbokvNdaXUTGlzAraBOOHh26uu7f5J3RCg6/jko5rCD+Kt+C9+M7txxzJ q3GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b="T7R/VZW8"; 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=wp.pl Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m21-20020a509315000000b00447820ba16dsi1715540eda.434.2022.08.24.14.58.54; Wed, 24 Aug 2022 14:59:20 -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 (test mode) header.i=@wp.pl header.s=1024a header.b="T7R/VZW8"; 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=wp.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240520AbiHXVyO (ORCPT + 99 others); Wed, 24 Aug 2022 17:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240350AbiHXVyD (ORCPT ); Wed, 24 Aug 2022 17:54:03 -0400 Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD07754B4 for ; Wed, 24 Aug 2022 14:54:01 -0700 (PDT) Received: (wp-smtpd smtp.wp.pl 5393 invoked from network); 24 Aug 2022 23:53:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1661378039; bh=jwWpS/IEJkDxPHdX0InnvrmEPux1NMA8vD9SgE2jV9I=; h=From:To:Subject; b=T7R/VZW8P/HHLnTPdHCIuaAqb1fvr7cFnz2Zw0EtkWQu24o1hf+BAgpdk9siXnqtn Rb+qtdDfOU1i/SKAy4XfPkjApYUu1mDms8fmjW3lMlmm+LszSNNvhkg0+CNcXe0zuV XXO1DvbPT9qqUY/Z0zjQNofbYWzg9eFY/ukiMRFU= Received: from ip-137-21.ds.pw.edu.pl (HELO LAPTOP-OLEK.lan) (olek2@wp.pl@[194.29.137.21]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 24 Aug 2022 23:53:59 +0200 From: Aleksander Jan Bajkowski To: hauke@hauke-m.de, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, olek2@wp.pl, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3 3/3] net: lantiq_xrx200: restore buffer if memory allocation failed Date: Wed, 24 Aug 2022 23:54:08 +0200 Message-Id: <20220824215408.4695-4-olek2@wp.pl> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220824215408.4695-1-olek2@wp.pl> References: <20220824215408.4695-1-olek2@wp.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-WP-MailID: 76d42ead0a5cd8b21ce83a0f3eabf283 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000000 [YdNB] X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 In a situation where memory allocation fails, an invalid buffer address is stored. When this descriptor is used again, the system panics in the build_skb() function when accessing memory. Fixes: 7ea6cd16f159 ("lantiq: net: fix duplicated skb in rx descriptor ring") Signed-off-by: Aleksander Jan Bajkowski --- drivers/net/ethernet/lantiq_xrx200.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c index 25adce7f0c7c..57f27cc7724e 100644 --- a/drivers/net/ethernet/lantiq_xrx200.c +++ b/drivers/net/ethernet/lantiq_xrx200.c @@ -193,6 +193,7 @@ static int xrx200_alloc_buf(struct xrx200_chan *ch, void *(*alloc)(unsigned int ch->rx_buff[ch->dma.desc] = alloc(priv->rx_skb_size); if (!ch->rx_buff[ch->dma.desc]) { + ch->rx_buff[ch->dma.desc] = buf; ret = -ENOMEM; goto skip; } -- 2.30.2