Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp369083iog; Fri, 24 Jun 2022 05:46:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uZjq26npP1rEk9NhMhsCBbW/h6OV985g0dBFG7Vf+VapenaP7IMlSjLrtweHIw6ybqGTDb X-Received: by 2002:a63:555d:0:b0:3fd:5d54:2708 with SMTP id f29-20020a63555d000000b003fd5d542708mr11778572pgm.92.1656074798143; Fri, 24 Jun 2022 05:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656074798; cv=none; d=google.com; s=arc-20160816; b=H8SGGPDOE2PHjC7F4aQC3PdkmwwQzP73Dbq8/w6SOaqQ1Bmp3qyxcTqFIMWLaJY8TG 7NVVLnRxWJ4WlmODvh0t7OujD/oWnWFgTFq04C7htdpx8ujpVxxdKiKaAhNVKcuOpbtz fNYRAL/y6FmvUyz5pa7RtvzntCSEgyDnrwDG+KftgGDa9hNTfSwllOmoifqhPKgNdZRT sO3104vBeqI5KyDVAcIXoxbyhpARy052LDUAb9NkoYZZuNFijmTrLtCjTTv2a85CnJ96 nYdfjsFHlOZ5sWAK4ef4ROGC7gilLf2b0bbO5E/8jXwTOkO5LCty/3xk2LPQCv59OVos khjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2nQO6CeYq5fKHfv30czV2m4ZtSM4QjltO0wwv/dnqkA=; b=RnBhZ+pwRGNZOKS2OQGvUiHo87fI5eG5I8BsYAcP+0Q4jWkub3NMsIlq4cTuSeB4FV QWmIizIyY9XQ83qQz2iXtCyw7JW5ktQMGuTi6t8OiCZrdcp6VWpgl5ZyRzYz2J0EU9u0 X0o3E4S6cqsXfK9jEM0amd8u6njC3FcaovR7Zs1Ih/OoiQkjz6Yd+2LDGN3iOe1Rtj7J Lr+Cia9WxNchdniBZ1IkXx+C0AwVWw//iBziQ7zW67xGbkOMX0MRdaFZSWqlqYJoJzew SzEt32BlS+yS3ydmRzcqj4nF9dyB4qH3hNrphUbvfw33CMxjRdesOG1nUw7kTvGxpST/ KXCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pj0s49K9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a170902bd9200b00168ebc82df8si2940304pls.61.2022.06.24.05.46.23; Fri, 24 Jun 2022 05:46:38 -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=@google.com header.s=20210112 header.b=pj0s49K9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229603AbiFXM3p (ORCPT + 99 others); Fri, 24 Jun 2022 08:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbiFXM3n (ORCPT ); Fri, 24 Jun 2022 08:29:43 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0D9A4B86B for ; Fri, 24 Jun 2022 05:29:42 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 15so4274165ybc.2 for ; Fri, 24 Jun 2022 05:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2nQO6CeYq5fKHfv30czV2m4ZtSM4QjltO0wwv/dnqkA=; b=pj0s49K9iGzTNZ9BU6izO5Hh1ZIt1MaYN4ZXoSYBHkReYDj2fwnN13fi9Zd5giPvJ0 /xcBXDwwmd4TSi/KCN/QhCRqkUZdkzJHxjssFmBCVQFIuNwA9l5IJd81Uc9l3QoR7LUD uWYCrDkdwZqKugVguoxl8F4MMqMVi5fda4NtYPorHFU2nPDyC4XyhnHLSJi8kZ12rUkg 9rDsg4ONoPe+xVVd+Vp5XSMqh4DIQSAIsMVuIhoI78un5BOZN8Lz9FHFp3LjfsIozg3q Hq2eBOoOzCChEAy7W+ryEl9mdw0MKsU2NUYQ2MzjtairrsmKCibNAbAHB+DYBFo38QcJ +WVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2nQO6CeYq5fKHfv30czV2m4ZtSM4QjltO0wwv/dnqkA=; b=atW2nSj8bDt897HbOe5MDCNiHvwL6pPfjnMllKAYK36mApPnVB/4lFMeHnRW26vPzp WtMNUGt3ILiEU14gRHKij3IRjL39TSR8daS2cVuKju4PPUMfTIi8xxKzj3rizcRUnGk5 VeNYnz2h1g4UpAOTVDDUaeXyIWEpQOOIAov3hvKvUe9pjK1xJpNndhqtjDPmk/RA2YBI ytrbKD2bYX7uFiY/VkAX0Vxd9q19aU73KlddhwXEz6+YbK+5KANnnQZck5ZF8a4lPBYE b5yWD9Bpr1oOXxhHbVaGay9Em1SbYIrctV44iNDDPY3Ip2PHV0y8Fd/mV1vOoknFzJ1w AdWQ== X-Gm-Message-State: AJIora+i0v17Z4kJ2eBJl3RyUvN2tELYB+ox77ER1jplx9JRbR2IgcHT ovbasFx9RGv+Nws0xcXl+OdrmGiyE1rWzU1szk302g== X-Received: by 2002:a05:6902:a:b0:65c:b38e:6d9f with SMTP id l10-20020a056902000a00b0065cb38e6d9fmr15283526ybh.36.1656073781827; Fri, 24 Jun 2022 05:29:41 -0700 (PDT) MIME-Version: 1.0 References: <20220624041217.1805512-1-niejianglei2021@163.com> In-Reply-To: <20220624041217.1805512-1-niejianglei2021@163.com> From: Eric Dumazet Date: Fri, 24 Jun 2022 14:29:30 +0200 Message-ID: Subject: Re: [PATCH] bnx2x: fix memory leak in bnx2x_tpa_stop() To: Jianglei Nie Cc: Ariel Elior , skalluru@marvell.com, manishc@marvell.com, David Miller , Jakub Kicinski , Paolo Abeni , netdev , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Fri, Jun 24, 2022 at 6:12 AM Jianglei Nie wrote: > > bnx2x_tpa_stop() allocates a memory chunk from new_data with > bnx2x_frag_alloc(). The new_data should be freed when some errors occur. > But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns > without releasing the new_data, which leads to a memory leak. > > We should free the new_data with bnx2x_frag_free() when "pad + len > > fp->rx_buf_size" is true. > > Signed-off-by: Jianglei Nie > --- > drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c > index 5729a5ab059d..4cbd3ba5acb9 100644 > --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c > +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c > @@ -789,6 +789,7 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, > BNX2X_ERR("skb_put is about to fail... pad %d len %d rx_buf_size %d\n", > pad, len, fp->rx_buf_size); > bnx2x_panic(); > + bnx2x_frag_free(fp, new_data); This will crash the host if new_data == NULL Really, given that BNX2X_STOP_ON_ERROR is not defined, I am not sure we really care about this ? > return; > } > #endif > -- > 2.25.1 >