From patchwork Mon Oct 24 11:32:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp519283wru; Mon, 24 Oct 2022 08:41:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6M7fMcpzpZm5mxVruGZk4IUfIQQNk/w/cZIzdm8CWyegOQDUO01VSTzixCUfRku31KSiZo X-Received: by 2002:a63:1a53:0:b0:44d:e5ba:5acf with SMTP id a19-20020a631a53000000b0044de5ba5acfmr27648227pgm.461.1666626088245; Mon, 24 Oct 2022 08:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666626088; cv=none; d=google.com; s=arc-20160816; b=UxoP2QKvcwMjfO8/2tHD061Xhh1rscPnxFqovqyZNNv24/KkaWropINohI2h0l8D0P 5PmN720yT7kae1IgXnCG+lbIgzGu+INSlcXvW0jyH4SFshovUB90hDc6OLGOVCm8u+6D yJGP6zlK6/UWtT/XC8iX7F4ISmHmagiJQEF6sff5ydQ6/jHTHAy6nVVb+7M9qUysRp9F Y2T49n/Rtqh528w+RQ9aDNf+OgojysmqjHSdykPe0e6QspNEgL0air2ax3gOEnavbjBq xQWYQuUp7EJoA/HXoNWP9eUO8qCsTS9EyOVcOgXF5pkIVHS8IzqBAuNcKIwCU5IflKNG +BQw== 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=NFwgjsoyaOJesc1Ss5O4VCV1gJR4V/TL4H1W8uGcVg4=; b=ZqOsD4uqs+cVtiBnCGBHX9W8+KXTd98NiI5F4hjG/MUT2m9NNfEH8KGttImGHcTu0w D1ltyg5emikmJUfvw3QOSaXTQjiXcBDHk1RKe1lBZBKFoCX7IC4q464910MI9CQujTCP 355sy2VqzvpDtOEYh2LhvWMGqPweHpY/cys74mnEJtohEI7uB1YkvE18IlCwpqoDRDCg 5UmgXxnSWg8M4ULXiPwivtQmhHvGDLI30zUTW4rukXIf8HpzyBwkyl7ppetQ8OrGRCqO R2n4B4TPsoFrxuPIDq533Cz+tJ13P9AXgBfZMcIZqopbVbOM0hEy0+Sh2HmfcV9E3B4Y jFZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=csh7SZMD; 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 y4-20020a056a00180400b0056bc14f1cd2si12517pfa.10.2022.10.24.08.41.14; Mon, 24 Oct 2022 08:41:28 -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=csh7SZMD; 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 S231397AbiJXP2I (ORCPT + 99 others); Mon, 24 Oct 2022 11:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231944AbiJXP1m (ORCPT ); Mon, 24 Oct 2022 11:27:42 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD5CC8963; Mon, 24 Oct 2022 07:13:54 -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 sin.source.kernel.org (Postfix) with ESMTPS id 2517CCE13BD; Mon, 24 Oct 2022 12:31:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A37BC433C1; Mon, 24 Oct 2022 12:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614696; bh=XP41Tj68mNCGeN/XBl6NTU46Edzwp7ROZmpjlXBJb6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=csh7SZMDSmgkMviDuzdgqgpQfpcAmtGnHVIPI19rr/KoS8GCZqIlsOvAIbeNhV71L mWJHlKCkJ/d4XrQ8ilZYw/E5nB5RYEaZSwAwEgC2wNiNJZjgZqR6okBvlnD2Oz3Ckb Tu0bqceXcuwFbGSn7LFOhf90KZ+d4fg4agyoVBaQ= 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.10 360/390] staging: vt6655: fix potential memory leak Date: Mon, 24 Oct 2022 13:32:37 +0200 Message-Id: <20221024113038.322912201@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747584117120881045?= X-GMAIL-MSGID: =?utf-8?q?1747584117120881045?= 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 0dd70173a754..343f0de03154 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -675,7 +675,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); }