Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2255506rwn; Fri, 9 Sep 2022 10:39:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6WFNbfmqCbETyQXmkOBATb2STezswpfVRs+DPuKk915KqyaHBylRjox4Y3lxeqdwiLx/9F X-Received: by 2002:a17:903:3294:b0:176:8d60:b947 with SMTP id jh20-20020a170903329400b001768d60b947mr14377101plb.56.1662745196368; Fri, 09 Sep 2022 10:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662745196; cv=none; d=google.com; s=arc-20160816; b=XjCUzT25FrTqZ9GcLE/EFjC8//nZ9L3LdVoVFGBxbt5wcTGWcFk7+AxnAIw2sRnVCZ 7fQs4YFSBeEZu2kHPI1gry96KzFA4KNu+MuwKEW8i2/xGF7YyK98tccJh4XCjYFpaWbY FcM+nvqi0ceKS/kOh5NHNPx0eo/hfUewNzaaKmhos2KBQledSd7PEfP/Y1UKW3f2uc/1 U4ynyMJY6rdeaEg0GL5MiVscRKd9rCH0Caobj0YuWmieHjIDZjYzVHBop/yK8dkZdRqK xU56MhbCJ4vT3+JwKWRiVudbchnzZdOkUAvgLxs7SmM0nSsgRAh5LDMoAX9rFn03ChHG URpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=KBKK7iFKML2I5N/b2jqG9ifqUfWsm45jjFjrGgVshBE=; b=lAPkZXMc2dYHm1GZbJwsx4RgFB5eSqaMvZGEs9VH/K07/sntGY2fBRyImml8Pw9s1c Gpt1vROsYUkQXBgk9WkO2eWOCQ8cGNPYkwWYSFlUW4qZOhDSk9Y7aqbaNuiwLXGGF8+m 4Wq141y350AqhjN2nMD8zF8hYe4ROlDqSJJT1KrOC2Q3brhBq8MzXJGnOpV6auTLWiRP ItvzmAOm+9ai9GGECYKT7RhLrcPd7eFwQICsfUN8IHQD5tTFaWNUX2E6iF9jzPOfXFC6 aoojqK51sxmYGheQW1RH8Qhnfgl3z0a1j57z0fCDfEnMgBw0RiuXZUb3jJgkHsGqNBmy oqOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="CXT/bIwl"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a17090aeb0500b001fe1add9c77si1001831pjz.187.2022.09.09.10.39.43; Fri, 09 Sep 2022 10:39:56 -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=@gmail.com header.s=20210112 header.b="CXT/bIwl"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231493AbiIIRbm (ORCPT + 99 others); Fri, 9 Sep 2022 13:31:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231557AbiIIRbg (ORCPT ); Fri, 9 Sep 2022 13:31:36 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB31125193 for ; Fri, 9 Sep 2022 10:31:33 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id y3so5666585ejc.1 for ; Fri, 09 Sep 2022 10:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=KBKK7iFKML2I5N/b2jqG9ifqUfWsm45jjFjrGgVshBE=; b=CXT/bIwlhl3oInco0vLlYWMvsALVMY9M2FFs4ZDXwEhUp9cwFSr3qLXyM2A+PlY/oH QIaE74MiTVwaYm8RgF/qWf8673QmZ8EmkBBjgtZa+scTL6LUJcfaNm7daNXdKNoc2HG+ VPdeoQYnifePI1QUxmFiFUeL8+KaUePebSlJlE33OVrz8vBaDl7FYiMcpy168xGHp9Ty Bq3xS/48JbXF4YyrRX+Oczyl7jPMGuNSmszRoVFM30rA9hVr1n6owsQryJsAV3Gi+78L 64jMueQqe/Kbms0DqG6Q+nMhJV4HRwWT7ATbXXs5zp17fkDFoQMnagvScpFPIw/nXdn4 D+Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=KBKK7iFKML2I5N/b2jqG9ifqUfWsm45jjFjrGgVshBE=; b=Jm4YL451CHab6HWUpDvH5rsDxBMBbJntnqY4EDGixqofKtXqJDfLfdIdAOwpgUVaHi NthV8L9zO+ouSDxTRYtuZstQpqa//STBLs4XUDubDaIz5krR8hf8iJ4F5x5HVBV/E/F+ qqhorW2GDY2qqvWAlJ835PPNCfU+aVe1lj6U1uUUClk5QMcvqpOr9vurj9C7oQpWU4i6 OQL99x4zeWr6TdO6AYy0wU252F3aSidx3VXQqObNffen8Z2Qfrv9VRyoMPEN2+zf5umb 6ka7JteUImH4uy5vlB77w1U86/U56H9lFnvW79d3O5ehn0kWHB7fhZEiHxQSGgJh4xyv iD0g== X-Gm-Message-State: ACgBeo3XK1+qc25Mmt1k8XLnDFh7jYclEl9FhLESm5pjHLQCJBOIOzx4 RoMT4wFyy3ZmB7q+lCY8KIs= X-Received: by 2002:a17:907:7292:b0:733:1965:3176 with SMTP id dt18-20020a170907729200b0073319653176mr10437381ejc.318.1662744691733; Fri, 09 Sep 2022 10:31:31 -0700 (PDT) Received: from ?IPV6:2003:c7:8f3e:6a99:2499:da3b:c93f:9b48? (p200300c78f3e6a992499da3bc93f9b48.dip0.t-ipconnect.de. [2003:c7:8f3e:6a99:2499:da3b:c93f:9b48]) by smtp.gmail.com with ESMTPSA id f9-20020a17090660c900b0073c80d008d5sm531354ejk.122.2022.09.09.10.31.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Sep 2022 10:31:31 -0700 (PDT) Message-ID: <659ff470-a912-4f35-6cbe-e3f49ba29dc8@gmail.com> Date: Fri, 9 Sep 2022 19:31:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v4] staging: r8188eu: fix potential memory leak in rtw_os_xmit_resource_alloc() Content-Language: en-US To: xkernel.wang@foxmail.com, Larry.Finger@lwfinger.net, phil@philpotter.co.uk, gregkh@linuxfoundation.org Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org References: From: Philipp Hortmann In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,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 9/9/22 13:44, xkernel.wang@foxmail.com wrote: > From: Xiaoke Wang > > In rtw_os_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 add 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 > --- > ChangeLog: > v1->v2 update the description. > v2->v3 rebase. > v3->v4 update the description. > drivers/staging/r8188eu/os_dep/xmit_linux.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c > index 89a598a..f25099d 100644 > --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c > +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c > @@ -75,8 +75,10 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb > 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, I cannot apply your patch: kernel@matrix-ESPRIMO-P710:~/Documents/git/kernels/staging$ cat ~/Downloads/\[PATCH\ v4\]\ staging\ r8188eu\ fix\ potential\ memory\ leak\ in\ rtw_os_xmit_resource_alloc\(\).eml | git am Applying: staging: r8188eu: fix potential memory leak in rtw_os_xmit_resource_alloc() error: drivers/staging/r8188eu/os_dep/xmit_linux.c: does not exist in index Patch failed at 0001 staging: r8188eu: fix potential memory leak in rtw_os_xmit_resource_alloc() branch: staging-next repository: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git Sorry Bye Philipp