From patchwork Mon Oct 24 11:33:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp554850wru; Mon, 24 Oct 2022 09:58:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7aF8KEBlOvXz28fNAJdfq3hJBeIYCJXZwZW0dsj8OaK0ovHctgrJMCtDAi3GDmMV107laC X-Received: by 2002:a63:f706:0:b0:462:4961:9a11 with SMTP id x6-20020a63f706000000b0046249619a11mr28398123pgh.462.1666630694011; Mon, 24 Oct 2022 09:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666630694; cv=none; d=google.com; s=arc-20160816; b=0IswCyRXHJYDXX7+6ZN04DMyrxSIGBct4noQPJ51dZCu5H6YnOcNDPYOsQQvE7BzHW a4U1a9j/AiqMwCvowpB+FOBwpLEfQCNTpg19GbR1CqA4kkSYZ0YBHyGYIAeBxirInUW5 tyafRXzdu3Q0jHTCNquI6lxjUr4opgB+qrrE6sOzWdXtxZGmbGETQl9VF8fwGRglJUqm PplvaSXSxk8+8hxPAggP1giX90wZV6B3gtLSu2+WLfEBpEqNcqTZ3K3eX5izMk+qEURl HGkt3Vc95TGFehLY9PkGkiVkg7E27Q2zoasrdJO9q+vl0ozuJx3sOf5kQd1W0B5SpddE 8DHA== 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=eLLqO0RyB+KtLVO0x9u/6K23tnqaI4h91GoQHhZDkso=; b=upfzvQp5AegR9ATqwHDk481bWJyU2FQfnfVorhcw+pDfLsmPhi0UtaWm0i45k1vy18 ZlO8e/MujK+I341/f3DkWGKyt5+e+I+YDwoTMfIxDOiPqvPE5RMps9+7hqeAKuclZhab DcH9iHWGclJ1OXwCga050I04SiSRNJzodXZHHAj3SHey5vL7EZ6m92ib+tZbr/vEhdr7 5GWVEr84AoMNQirCLv6qUTymBaQgZ2KQLgoOIfFjB/Q5OOx4muQXNjIdlXILKvTsn+ga HrnutoHHKnqvwVwrcg/mko39d451YboYcAhum5Sdqn315AdNRch7dKWQQLMkGa6OqFhp NKaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WxdChtMU; 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 t19-20020a63d253000000b0042c3a5b699asi16885091pgi.783.2022.10.24.09.57.56; Mon, 24 Oct 2022 09:58:13 -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=WxdChtMU; 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 S233646AbiJXQws (ORCPT + 99 others); Mon, 24 Oct 2022 12:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235237AbiJXQtQ (ORCPT ); Mon, 24 Oct 2022 12:49:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2A9E31375; Mon, 24 Oct 2022 08:32:22 -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 3F4FBB819FA; Mon, 24 Oct 2022 12:54:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EFD9C433C1; Mon, 24 Oct 2022 12:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666616064; bh=0kXO5B/LPn7NgpyXDfDUUEpfUw3v67CHR3ou4Xlqh1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WxdChtMUcRV7ID89TASDvLm830RrB4eZDJTkafBkoS154cSICtgWKiSJKOPa+sBsB dEBq/wvqugLZBAiqWhux28yG8Vy6cEb6cXdtizX7VoFu3Z4rgrkixX8sa5wG2KIE6C 2x+UnP9EYoIzBdKDojKAsR4DK3x0YB74+VWZq65s= 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.15 487/530] staging: vt6655: fix potential memory leak Date: Mon, 24 Oct 2022 13:33:51 +0200 Message-Id: <20221024113107.098703320@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747588946703920135?= X-GMAIL-MSGID: =?utf-8?q?1747588946703920135?= 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 43e32360b6d9..775537b243aa 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -676,7 +676,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); }