From patchwork Mon Oct 24 11:32:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp687116wru; Mon, 24 Oct 2022 15:45:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6D6Oo9hmVyJe3aLR+rbOfW7H0iyqmhGt0eESucUlO8Fi7HquaK7ho8YB16K1nNQ5sGXfrQ X-Received: by 2002:a17:907:75e9:b0:7a4:31c:ae0d with SMTP id jz9-20020a17090775e900b007a4031cae0dmr9695557ejc.79.1666651544012; Mon, 24 Oct 2022 15:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666651544; cv=none; d=google.com; s=arc-20160816; b=z6kqQYFFsJTiHu+/Ho90tIecQ9saFGFrjH8OQy7FmGGbkFUcB+poECBD64V22kxKVA oisVCbGbd1ou5j8kB7xK2nDM8DbmQaxgzT3Rv9AoT3yb4rY2CqlIUvu4w68UwnvgvfsV lYw/TdmBe4Wqe3tsbNRZvfga5pamXybS+9t8HoJmvSJWwgq57WFLEySxYqMWVMghcDSG xINp0aaaJLi87R02tl6kOpFTQbpLH0+03+AJJxU25habRqj6GIE6+9ZioxFqC2HE3uKJ B1L9TctPxARciOU7fmNPZ2+ZNJv1NgKuB1/KKyiddtWAcKnASkqpi/o22X0/d+hSTYtR OTXQ== 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=dV+E+SVR+hzUjvYfGEUNH4a8MbNKJr+ppYqfr/L0XDc=; b=ypwQQS4BBpV24ArQpebqMfvJNHKz8pzkh57h2ukh0vzQPuo6/+OIJjgogykqkAGF2y 3AReysLxvS1t3CUNcWspRl8tZvZpd6LofqC2zl9kfx/zl3MkTosYp9Z8aHPlcX5XoF5D MK+CRfFjSFfTowr3PPO5lqW8ok+PY6JWjPemeQNCnmPEAvv8rovoUp5mvZnrjjvwkqeD lOra7cNXRmrumRpG/v6Finq1IlmX5/oGEasCnIHcvrr4cRnz0CW1oza+ZEJZ1zhuBZ6z ZnGL4W9AHz75cIyNeC3gpVElcEb4048K1yRrieX/jVJFDGBipD75qRje6ZRO4OD71l7A VjYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cG030Kg7; 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 qb40-20020a1709077ea800b0078db1258ae9si984426ejc.555.2022.10.24.15.45.20; Mon, 24 Oct 2022 15:45:43 -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=cG030Kg7; 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 S231890AbiJXWov (ORCPT + 99 others); Mon, 24 Oct 2022 18:44:51 -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 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?1747610808952680054?= X-GMAIL-MSGID: =?utf-8?q?1747610808952680054?= 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 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 *priv) return 0; err_free_desc: - while (--i) { + while (i--) { desc = &priv->apTD0Rings[i]; kfree(desc->td_info); }