Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4122932rwn; Sun, 11 Sep 2022 05:44:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ZLOU9c7UCCsinwBiLVc5Nq+L/g6cBd08o0Yl+8a4Ob1ho/pVQLJaX9wnujfej5Lr12Xgq X-Received: by 2002:a17:90b:180a:b0:202:ae1f:328a with SMTP id lw10-20020a17090b180a00b00202ae1f328amr6546793pjb.78.1662900292781; Sun, 11 Sep 2022 05:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662900292; cv=none; d=google.com; s=arc-20160816; b=RZ9Yg/nC7YaY1dRgGwqCsauF3gR4Kiz3OTXkLjF4NX86sgjSUTatdWOsfCqIlP0DYI M0PfVN56O6xjtQAAwFG8VReBaLTIytPKFRM0kQfk8QwqQ45kcoSoAi0/0oZ/hM5mnZi5 WMG9NfybGcdrxq5epLBdnYl8R77fhttuOQqZP5oLeYsvR9PNlId4+kkFsFdmBDIDjVaU 2G/gR9Ay9RX9pnbwbGIcKoyS/HAxBmTtEiBbqA0sp3pv8v0+ibYcW+b0ehQcbdrXf5a/ Ui9qzL+Xpxt+vxKRiWp+ConGVppMZEPhQYI/T3HwopMQ3hniqZNEwsmnt2ZGVTz24UGf 1fmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=tPeCLiMIchdGgFXWVEsHHujbVNwWYMrXwxndOwcU4MI=; b=AZk89V2Ab7bAO546rm0BrdBSauiE6P+LPxmTwm0vhGj4Rd7R+XKIBKnXgE4zK8f/jf dFoyu8SDbyhBe8OQ9WqmBuNvOTvG1rQVR8uK9aP/6R8BUa5gO6604qSyLXkhC2u7PPso VB+DGSJ77FkDe/J30CdnsYxP79u4ziscxScHrN6AZuA9EKaI7Jr6z6BUJgQa2/6fo4/I YeJhlgAXa/VoW1F3XBLD4Q3TqY5RfkYETBRCfLJPjyjT3tP6kvwMqCzcVwvyPXTz1dTO qV0vXWb6jevOwyISP5exOzVwyAMl31mDSU5tyjaFGdrdXv8BbY2OpLhyGDA2+Q6/HMLW /sHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fPUKjbOc; 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 z12-20020a056a00240c00b00542d64d4f76si1909678pfh.27.2022.09.11.05.44.41; Sun, 11 Sep 2022 05:44:52 -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=fPUKjbOc; 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 S230102AbiIKL7k (ORCPT + 99 others); Sun, 11 Sep 2022 07:59:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbiIKL7h (ORCPT ); Sun, 11 Sep 2022 07:59:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33F411000 for ; Sun, 11 Sep 2022 04:59:35 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1846C60FF6 for ; Sun, 11 Sep 2022 11:59:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 217D3C433D6; Sun, 11 Sep 2022 11:59:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662897574; bh=4Jbss07D3ML9Z0J0BQzLGO84p1atHK3C7/kFc+KRRW0=; h=Date:From:To:Subject:References:In-Reply-To:From; b=fPUKjbOcgd59h8FTkJN0YYt+0DMo5NW0idEd+QpmoXjpFgWxzWS2NMrC68g7aoa1R Zn6D8Tkoy/BH7VZEl5GnFdaBDSRwvN0LEpc/xqwrT9mTcYFRx3nhNcywxyGykgXrEH /Q8gHd+WtiLcGU217FjsjjBSz2sT6zUdncJ34Ayw= Date: Sun, 11 Sep 2022 13:59:41 +0200 From: Greg KH To: Philipp Hortmann , xkernel.wang@foxmail.com, Larry.Finger@lwfinger.net, phil@philpotter.co.uk, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: r8188eu: add kfree() on an error path of rtw_xmit_resource_alloc() Message-ID: References: <75e8636b-71f4-1334-47c6-0e60f26a2d0a@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <75e8636b-71f4-1334-47c6-0e60f26a2d0a@gmail.com> 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 On Sat, Sep 10, 2022 at 08:29:03AM +0200, Philipp Hortmann wrote: > On 9/10/22 02:29, xkernel.wang@foxmail.com wrote: > > From: Xiaoke Wang > > > > In rtw_xmit_resource_alloc(), if usb_alloc_urb() fails, then the memory > > `pxmitbuf->pallocated_buf` which is allocated by kzalloc() is not properly > > released before returning. > > > > So this patch adds kfree() on the above error path to release it. As there > > is no proper device to test with, no runtime testing was performed. > > > > Signed-off-by: Xiaoke Wang > > --- > > drivers/staging/r8188eu/core/rtw_xmit.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c > > index 67f9c05..9c39d08 100644 > > --- a/drivers/staging/r8188eu/core/rtw_xmit.c > > +++ b/drivers/staging/r8188eu/core/rtw_xmit.c > > @@ -44,8 +44,10 @@ static int rtw_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *px > > pxmitbuf->dma_transfer_addr = 0; > > pxmitbuf->pxmit_urb = usb_alloc_urb(0, GFP_KERNEL); > > - if (!pxmitbuf->pxmit_urb) > > + if (!pxmitbuf->pxmit_urb) { > > + kfree(pxmitbuf->pallocated_buf); > > return _FAIL; > > + } > > return _SUCCESS; > > } > > Hi Xiaoke, > > I applied your patch and tested it. That is OK. > > But you excluded the change history. Usually this is not accepted by Greg. > Reason is that what identifies the patch is the change itself. The change > itself is the same as: "[PATCH v4] staging: r8188eu: fix potential memory > leak in rtw_os_xmit_resource_alloc()" Even if you change the Subject, > Description and the branch it remains the same patch for Greg. Agreed, please fix up. thanks, greg k-h