Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp422784iob; Tue, 3 May 2022 01:01:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHaURqkISwlHIZsXdKbNK5mb2E0/kPaEZpcqqUduTOZRl6iInY3HRxf1G3aSjgRXlClw6y X-Received: by 2002:a62:ce82:0:b0:50d:512f:7b76 with SMTP id y124-20020a62ce82000000b0050d512f7b76mr14885197pfg.79.1651564871571; Tue, 03 May 2022 01:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651564871; cv=none; d=google.com; s=arc-20160816; b=FR682/aENGSTm+oSNfCK8sqIFl+WspCoOSuXwwqmEC2XXxp6wzR4x0oixzRzLOgcPW l+F1L3FBb1v1p/6Uqm+ij7L4SEZ3mRWkR6QjumoCl5T+MjFaT6nMASAteSPyBP3Y1ETL pJWNT8MDiyIEjZQx8TeE6yMWYuKHlP3DNL9mOHjNJOHQAX5UcnEso3WOXB4TTIQJsv/t YdbFugZ+zvs2vuYeMrCeS9XNJdIdk6Kk/mbTuhTfQYtwV2u1/iCc3MO4Z3XWev3694DC BoX/CbKhYrGjduqYK/4br1bEx57ezSQmUw3uUo/OwQJPkZX2c73cfLU7scp0YtOCvppe e6jg== 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:date:subject:cc:to:from:message-id :dkim-signature; bh=9FDEMiTl+z/wCxW+Guf4auIR1peUkb2NVkPH/qZqMi4=; b=yQ8LWIWr8dFIkHEX8Uoen4pMORtYzL2J85P0BFV40QWASLKnRqPHnOKqNnuSFP4XTs qrfnA6JnYhkQj9QQP5ZldGLzsJ3P5rLjR0jwGhXzHbiChwWrK57dKaZu4mQiUxO5Tgma 9XWnf4Q1nFae8QlbbNlND28/NbW33jTUPl2uiuS0x0KZCkZKlHyJzSzgT+oV86Ot0ZQi XmLbmi8cF+NzmEK8rqY/3Lr/EuEHm+chhSSIYNfUo/2WmvuOUyPnYc+ObVNqBCdaf+Xb MIEg8avS5whkUmoag9fmAdd99ipGCy2hmRGdTqmpxyUPlpdKN88M75nsabhIfsApn7Je IgMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=Xv9RNCmg; 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=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020aa7954f000000b0050de0aeb46fsi5684204pfq.3.2022.05.03.01.00.55; Tue, 03 May 2022 01:01:11 -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=@foxmail.com header.s=s201512 header.b=Xv9RNCmg; 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=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231612AbiECHFv (ORCPT + 99 others); Tue, 3 May 2022 03:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbiECHFt (ORCPT ); Tue, 3 May 2022 03:05:49 -0400 Received: from out203-205-221-153.mail.qq.com (out203-205-221-153.mail.qq.com [203.205.221.153]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980452317D for ; Tue, 3 May 2022 00:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1651561334; bh=9FDEMiTl+z/wCxW+Guf4auIR1peUkb2NVkPH/qZqMi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xv9RNCmgpzLO0beVYFDlbaCwa63ue9gKrW6OdUzUCRdLoo+QfWWpdrO7pqCwrAAIv A2qSp1OSdg9TQnFiF73JUs0DZDbdKm9K4OtJTr3FmFqCuXCcMKYK177AtB+XmJfTKP olERmL6Jw3tTlCMEdl4akD9JwFr6avbtNYCNlz58= Received: from localhost.localdomain ([59.172.176.242]) by newxmesmtplogicsvrszb7.qq.com (NewEsmtp) with SMTP id 8C32A28; Tue, 03 May 2022 15:02:12 +0800 X-QQ-mid: xmsmtpt1651561332t81yuboxp Message-ID: X-QQ-XMAILINFO: MOZWoti2yOjR1WCeDO5N20SjV776IuChw0vIo2aGoKJDSYZyhu4uwROr7MlBXp rOGVD9kGn1+LpU3ojVGy8+Iy+S20GBygglWJ4kuPUNMvi99a02BckC5aW0RtbsfCL4gcPYewBsmt 4n80gh1/7M2hySPUT5HTdnLd1XeMIpoSAqNopkiBcvG54VLFfDtk8uDIszUiVtr9iu2uXvNlkVWV 7/rCDH/9gGAqBxGqEtZ4UzIpM5A14UEnLqiHybjH7qaAHkpRzgkGc/mJIqb6jSyLvszR3jPlkuQH yUn9f42x7Rcd15GaZHCIIjuNNJzjJWhnbk+mR8WW794ikqrvVjdA3lTWmHuE7AZpXBdK/EXjXqUD IpH1/8+K6rsgVO3L/GDVm3Wd/MypcwLAjeAvXXETW3Ktv7Cs1uhsj+IInxKajlxJOUBAUOaz07nP xUiDAi/1RFp5xtEmmar2f4e1c0eMDRSOaIjsDyJGEV5y+WVjmQ9Q/86bvWBpkbEURLAQH6ixJ1FJ kgXlI6FQpjjJBHUB7l9JxYhxYHGOIxBxV/PtPpsjCDCQS133Qpmrgu4kdM8Duo25erQFs48O7NvO hxL0oF6whaK9iXG4mrtpdHU3yqa+RvMPx2hVmHvVfx5FZEK0uvEoCeuBe0eqgG3E6tW/Tfd2Fq5u M5Z4Peq3x27rCD9A9A+jKbZ6Wk69tGhW89iBj5arnitRdZR+whGrGeXusOGyBJ9g4D3L0Gq/C7KG mXjsWKGM0TII9fM5G4MixMJzrJx2O52xGTLzNyobWZysPf8KbjnEUWYiY+PfWJ5ZQTUiKMFtLXhB jamR8k8EeddpYP7H7Md7pY57b39neajBjKp4xF1e3C2E0/TUvuMsoKkE9PgUuW5Mk0VR+YJ7G/Bf jD16BAHp0mtzl/jR+ZGtNwpLGk9CYd8AgpiVs4qRb8siF69FAg03MhR8/nqu2qcL96oTvg/UddsL tNm7TgVOgiGzUFqVZp0DyWtCm71bHeSusyzNcv8bjuvCHhCJaSdQ== From: xkernel.wang@foxmail.com To: Larry.Finger@lwfinger.net, phil@philpotter.co.uk, gregkh@linuxfoundation.org Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH 10/12] staging: r8188eu: fix potential memory leak in rtw_os_xmit_resource_alloc() Date: Tue, 3 May 2022 15:01:51 +0800 X-OQ-MSGID: <20220503070151.3369-1-xkernel.wang@foxmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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: 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. Signed-off-by: Xiaoke Wang --- 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 e430c64..0c448e0 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; } --