Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3062107rwe; Mon, 29 Aug 2022 05:19:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR7AqxTLSPHCpuLQfrn0g8X/OvEWYCb2zN3hSyv4byoAwUIlzqBscu/mnvaJ/a+w43RAF2HN X-Received: by 2002:a17:902:f78d:b0:174:f7aa:921b with SMTP id q13-20020a170902f78d00b00174f7aa921bmr1255470pln.37.1661775580716; Mon, 29 Aug 2022 05:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775580; cv=none; d=google.com; s=arc-20160816; b=gkI0OO+RWCK6ifZzp3BNghtnwY/u1Cx2ASqML6WLKUkyqTjTiSHJwBiVq6She0L+zY yYsfZpWqW/xSDFV36Zs8BC9guRkVQeG1ONIBmmjHV/If2j1+ShNKu0T4bH3DwdakpZ1O 4F+Pwu/oeYXyzaKpubbkpiChhiiC22cYW16IBVO2mYs6aLTUeD1230Z2bKyIOYLq+sNa 570s15cfmypo5OByFsj5RsutUDJh96TVhh0FfrB1FPrjuxM8K9JAdI58SsXOvK/c1xu/ WLLEeJVNgwjnkXlsVQ6yK3756n1MSAvdk5s9hkjoEv1g0/yz3on2e2FqnLniRRFqzuj9 dKwA== 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=hr1E/FKT/8R8BFdcDOdelD6uGPdzCSSgNvAS1VXNCXA=; b=Y+HV6LAj9+E/ZIIvYYmLUsOMmNN0USJb9HnEMVpQEpqrZ+cWXnO1DTh/OUCTveXmBf 4yAZGi9hnUMksGjQjXzWf04ec6lahOTDamqADuqc7zOAu7DhsmwBcSyeBnmVXGmiZw5Q AjqdF3bcPWOJOLmGtBj1nA8OogSbBCuIENoGgeGjhcewrLwm9z6t19MBoKFJgKE/9NOc w4u4hgJkCkUF19szIG+cDLER8Pp9RZJ8XvO8uSBwGGbxm/aEQbl8VviuB+qrk3d//kgS OVEeAyFCLtYIzc/pz9PJOI7wWGVoc5asOWkUDdL197925SbM/z88254duPEko/NUxsuB GgVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n5TKkEZu; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a056a00114300b005283d3bb832si9868034pfm.193.2022.08.29.05.19.27; Mon, 29 Aug 2022 05:19:40 -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=n5TKkEZu; 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 S231904AbiH2MSQ (ORCPT + 99 others); Mon, 29 Aug 2022 08:18:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbiH2MRu (ORCPT ); Mon, 29 Aug 2022 08:17:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3206AA2232; Mon, 29 Aug 2022 05:01:10 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0FC73B80F93; Mon, 29 Aug 2022 11:16:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40A7BC433D7; Mon, 29 Aug 2022 11:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771765; bh=AlpP6Cppu3aOPE3+U7DODj6l+USJkVNajExw8Z7AmVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n5TKkEZuqA+Ts0WPN0fsAH2r3fvjAzrM3/o3rD/DZSWyCkqKp6Ef84VjZNbghXTmD 8UpJxV/aqLez1DLFVLBLEvwienr3xvwhkeu/CNmjxSH9Z7qgkqeKYtTwNb+D7lKYV7 6a0lLb9+qW5TgT71/UrE+gNH4VTDQZ/kKLr0JM18= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Aleksander Jan Bajkowski , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 091/158] net: lantiq_xrx200: confirm skb is allocated before using Date: Mon, 29 Aug 2022 12:59:01 +0200 Message-Id: <20220829105812.881721584@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 From: Aleksander Jan Bajkowski [ Upstream commit c8b043702dc0894c07721c5b019096cebc8c798f ] xrx200_hw_receive() assumes build_skb() always works and goes straight to skb_reserve(). However, build_skb() can fail under memory pressure. Add a check in case build_skb() failed to allocate and return NULL. Fixes: e015593573b3 ("net: lantiq_xrx200: convert to build_skb") Reported-by: Eric Dumazet Signed-off-by: Aleksander Jan Bajkowski Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/lantiq_xrx200.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c index 5edb68a8aab1e..89314b645c822 100644 --- a/drivers/net/ethernet/lantiq_xrx200.c +++ b/drivers/net/ethernet/lantiq_xrx200.c @@ -239,6 +239,12 @@ static int xrx200_hw_receive(struct xrx200_chan *ch) } skb = build_skb(buf, priv->rx_skb_size); + if (!skb) { + skb_free_frag(buf); + net_dev->stats.rx_dropped++; + return -ENOMEM; + } + skb_reserve(skb, NET_SKB_PAD); skb_put(skb, len); -- 2.35.1