From nobody Fri Dec 19 16:01:09 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C270C67871 for ; Mon, 24 Oct 2022 22:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231911AbiJXWox (ORCPT ); Mon, 24 Oct 2022 18:44:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231878AbiJXWod (ORCPT ); Mon, 24 Oct 2022 18:44:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 328632D335B; Mon, 24 Oct 2022 14:07:23 -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 8520FB81614; Mon, 24 Oct 2022 12:14:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D53FEC433D6; Mon, 24 Oct 2022 12:14:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613690; bh=uMn96ZJPzqLtHZX/cUqm+tqU3zBy+TvPlLqdqK0lCXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cG030Kg7jw7/AfUa9qmT0miAGxZS4+GFEx2AbLq4ZHwLjUmhFFG5dcP2QvDlxawOO 4SjCMHvDEH//rWBlvsF7cPRt1s+eFxPIgoHH4R1QuIDBpIu1bEnKTRPQ/Gv7BUoAIP DN0A6Abdh5QHRtRH8PhgSiAakiAw7e8O91OJZm5g= 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 5.4 233/255] staging: vt6655: fix potential memory leak Date: Mon, 24 Oct 2022 13:32:23 +0200 Message-Id: <20221024113010.934162613@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3D0 is left out and thus memory is leaked. Modify the memory freeing loop to include the case i=3D0. 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 c1f9b263129e..18284c427b7e 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -670,7 +670,7 @@ static int device_init_td0_ring(struct vnt_private *pri= v) return 0; =20 err_free_desc: - while (--i) { + while (i--) { desc =3D &priv->apTD0Rings[i]; kfree(desc->td_info); } --=20 2.35.1