Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6824511rwi; Mon, 24 Oct 2022 06:36:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78csNfWK/5+lZEAAbLO0T3bn/ewFQgqKKQCEJAO1lywFrIXVZzw1sQWJ4pq3dhdGwT1mnJ X-Received: by 2002:a17:907:2719:b0:782:b261:e9eb with SMTP id w25-20020a170907271900b00782b261e9ebmr29218375ejk.104.1666618567027; Mon, 24 Oct 2022 06:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618567; cv=none; d=google.com; s=arc-20160816; b=FuXmUdl80VWdKIJzv5+Yt5QVAYT/mapH55BCWcdhh1AaF4zcU5I5Le5qmle0cLsRfF BsmNL4QMX3kg06DXKvc8n1oaCKlpH/YEEQ7wFSEeXbt1gwnEWzuZ5Q59MdLW4XA3gSLc OQJTfancq7hvmlygEdDQhUAdk7Ay9Nd4aMWMshUcl/IHSWEPakCeRx+FjkRHqcpznsgQ gkqHNTYyzYddVZB4lVviso5P39Vt820GD517Sei9B/iJNJi+PpMRwWLhVK6uG1iAMum7 wY3wQYSfUX/kr2Y+048hVL6r4CvM8iykbARJS7kQ1/rh3EtUO07vSA8zWaSfP3ctdBA2 U39A== 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=2Y3xQ8pO/9EUUdxrzSLB/ddlZ/VI5zSm4w1aaADmRS4=; b=FTy9ga0+XhhR2YPPAivz+WGfp8bxyQ9EwNs88QlQOBNXlSnsmL7f/PtZcjG+Vfgdtk eBjZZeTHOgAYJ5LdRPcM3KVC6+ubUZ1VZmPpyPQhC4IbG2a/38ZMlJ12aVChfGe35qIa lPZiyvZR1tkLbrUBVze1f3xYkugXzErrimJTM0NUTYHY3R2BEdRZnOTO6HwCSa/rsNZS mZbz/rMrfjlcdh1y2PlMq/2UmY1w8/7fSY14Q0iyglkPR1empc8WAQayi+rUsGORHmSP 4pUhQu6jdRT7vUC/xL80yrXmTLnWMr5qaLQnScEco0wBqTSMJHRctq9e+C9m95YbOdoG jxiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0dgQiFvr; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q26-20020a056402249a00b00461dfe5f99bsi1730948eda.298.2022.10.24.06.35.27; Mon, 24 Oct 2022 06:36:07 -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=0dgQiFvr; 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 S233052AbiJXNU7 (ORCPT + 99 others); Mon, 24 Oct 2022 09:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236102AbiJXNTV (ORCPT ); Mon, 24 Oct 2022 09:19:21 -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 A17CE855BE; Mon, 24 Oct 2022 05:27:49 -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 72B14B811FE; Mon, 24 Oct 2022 12:03:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1A7DC433D6; Mon, 24 Oct 2022 12:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613030; bh=59+QkenSEeOZ5nRSlBDnxK3mpHjFK5Nv+cNK/g2hqec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0dgQiFvrIp1/Lzjv5hLftCaIgs2zbtk8gL3ckkKXf7asDrj3NMhBpxIuqrATB/zMZ oUl1Qw5YzvDpntOlogVPpWqdadxq0/J4ph6P40QXBpts/+3htP5EVIB0CYTqK2dLCp op9pgQFrtdFYztsBhq4Oz7HcxcPoTuxESTxyyDiA= 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 4.19 211/229] staging: vt6655: fix potential memory leak Date: Mon, 24 Oct 2022 13:32:10 +0200 Message-Id: <20221024113006.033066607@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 cf86b1efa821..4c4432adb6c9 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -677,7 +677,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); } -- 2.35.1