From patchwork Wed Oct 19 08:34:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5038 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp247046wrs; Wed, 19 Oct 2022 03:39:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5O5vcrwe2x9naD8Sd1p7i5apcOPx7rCla281ztB5/AOY1b0UBhYgJW4I8qT5jvN3+LZP5l X-Received: by 2002:a17:906:5dd8:b0:78d:efa7:f78d with SMTP id p24-20020a1709065dd800b0078defa7f78dmr6185108ejv.641.1666175986348; Wed, 19 Oct 2022 03:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666175986; cv=none; d=google.com; s=arc-20160816; b=PxS6Kb/Rt9/A+F/t6IGyua84CDrcerjW55s+Xi/7U979WNpAf5lA4bc3fryL+wFQyQ WGA21Sjc7iRYwAuexJSfqO1C3LlAR2dCOO0AWQx8BEV/cCzUlMI3SEXKsKpoxiktDa29 h/evSMb0thsks6I7n6Fnng75mSSbCQxlhqgkywgwfbitIccVyEVFZHc3vJg/7tD1c1aW QmsE1mcroiI5jjNdAmqXbisZ6qa4ClStHl4m3Zw6OeZKBP2TCCCHihcDjTrySNHef44i WkuTiYBJUMSrnAquBtgM/DM2zotmuEJoihs9HGfjf5toK/5WF70nBsSmUOLWujwKL0Gi fwVQ== 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=4GZl9/SiHE2unzVo8bktk8QESgBtq7Ij6wx8l6lmPW0=; b=zoLiMkgrD/CFK0/xajQyScClLNJnwKdx0g0NT0ziTEiODJ5arCzK6SNagPiS/Nmdsh i563JsjYySQ+8jHvuUEijNjmLRyle38egu8KmVPVX2wE46DopnCS/Cj5hL/QZ5KUYbry 2R23NOhTBAUN3OAxMCpmugphdhde9NVX5QR2Y1ejnZ3zkcypqqtYnfKqhkb2nyTOBcU8 9K0PD2K9J86K48oiohFnpJ46neVJ9FsBaEqi1vbpUN4nHuH/sqhx1VJFeJd7oLF5ag1u 7kkfdN8C65B1/JDvz51b3rWqMScaSRfdp2l3gatqjndI07TEZBcj8iTW80nmKUCWsnEN G0Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="M/I1r/F8"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020a170906869900b0078dd22bc8d1si10863719ejx.198.2022.10.19.03.39.22; Wed, 19 Oct 2022 03:39:46 -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="M/I1r/F8"; 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 S231860AbiJSKi3 (ORCPT + 99 others); Wed, 19 Oct 2022 06:38:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbiJSKiB (ORCPT ); Wed, 19 Oct 2022 06:38:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E269A10B781; Wed, 19 Oct 2022 03:16:51 -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 B68A6B824D1; Wed, 19 Oct 2022 09:14:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1855FC433C1; Wed, 19 Oct 2022 09:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170840; bh=BIVRl7gCxK+enNuH8o6/GH0jH9Xla0sqrWO3iXWl110=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M/I1r/F8N0dAKdFyy9ch/4jdI7TbVWKuhhji++r9/sAyevGoTihZ23p3z2hvsufqA f/zZdm0TyiDWUmWKW3LtwY4iK6ifgTQw6SaepCLzToTRgAG+1aQ1RlGmG3R2vsx7gu CmQ3zb+dvScVHTcTq+2BoiWxtXx1dvAbiRNTqgBI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Hortmann , Nam Cao , Sasha Levin Subject: [PATCH 6.0 806/862] staging: vt6655: fix potential memory leak Date: Wed, 19 Oct 2022 10:34:53 +0200 Message-Id: <20221019083325.512077150@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747112151417342946?= X-GMAIL-MSGID: =?utf-8?q?1747112151417342946?= From: Nam Cao [ Upstream commit c8ff91535880d41b49699b3829fb6151942de29e ] In function device_init_td0_ring, memory is allocated for member td_info of priv->apTD0Rings[i], with i increasing from 0. In case of allocation failure, the memory is freed in reversed order, with i decreasing to 0. However, the case i=0 is left out and thus memory is leaked. Modify the memory freeing loop to include the case i=0. Tested-by: Philipp Hortmann Signed-off-by: Nam Cao Link: https://lore.kernel.org/r/20220909141338.19343-1-namcaov@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/vt6655/device_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index d76f65756db8..ec7c991e745b 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -694,7 +694,7 @@ static int device_init_td0_ring(struct vnt_private *priv) return 0; err_free_desc: - while (--i) { + while (i--) { desc = &priv->apTD0Rings[i]; kfree(desc->td_info); }