Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp181123rwi; Wed, 12 Oct 2022 18:13:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6TLvaRm9W4RxAaaV75cEvmyDGXal3MDXtZmzcDKiKBzdlStMRQoYK9qoE5cKXo00l3zYQ8 X-Received: by 2002:aa7:cad5:0:b0:454:88dc:2c22 with SMTP id l21-20020aa7cad5000000b0045488dc2c22mr30169260edt.352.1665623630988; Wed, 12 Oct 2022 18:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665623630; cv=none; d=google.com; s=arc-20160816; b=0UZo6kszpPXXHzdIWayaAkbt0valLU9EJ6adXOSEM16CcEXcFZUczvO7XM0vDdUXK+ eME2rymK3jakqfLfEa8+KV5cyf+8mfWaUJ/oCryNWvriCe8/9zNEPRANfTTkIj6JVvH3 6/6W4Mblqmhzx9QbiSRpD9h/Zab05L9uTXhvZy/ogYbac/HCOEkXJYsR0tUXmUo9+dWC WRgQ1jC48gY2dPf9b4g4J1py5cyPjgE5zahYIesaoT4Y4kVNyODWNJ7qCJPp7iZWFQK1 RkH1aXFwRmOWqFJ98GILWYCC0ZZDL41hd8zsWeWhOhuwmqrI1FjRFK+0lHovoKgTEFmb tTIQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t0VZO6JQaYp/STeBqNjJQdbj4EPratBg/42JXTytRWY=; b=zBDW+UhbnG4MZTtIINX2WLYVmJu0VpfO0RbuWZE/iB/Z7/NXr1XIzpxqTX8U+HsL5g 1H8a1UUZVAjqXkBoOH3O227sGiB1DojTDP8suxkJ6ZmKXVrLKtWJZsbGU506SkvQaIFb EKjmQXGAwTCBNv5zjGrDfFkbNnXzmVOH9B989tJjc+75eSvmKgsomjDD2GpRfgv6alao 1i7E0+oHHRhV3jw6vzFmJ3GEGsn8v7f4FbP7NwRoLibWJ8mH0uwEuX8R/MkHszvefRiH 9AoHUM9cPjREBWOmsYuT0SxKIVcXccNXh/BmqaNh7ifqCNMDI2BgXf6T8lphicp8tJpU kJmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Od4hR/e1"; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a170906178d00b00741c0bd7061si15329704eje.644.2022.10.12.18.13.25; Wed, 12 Oct 2022 18:13:50 -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=@kernel.org header.s=k20201202 header.b="Od4hR/e1"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbiJMARt (ORCPT + 99 others); Wed, 12 Oct 2022 20:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229802AbiJMARY (ORCPT ); Wed, 12 Oct 2022 20:17:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E261E1504B1; Wed, 12 Oct 2022 17:16:52 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 035B6616B5; Thu, 13 Oct 2022 00:16:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71390C433C1; Thu, 13 Oct 2022 00:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665620204; bh=WRtqGp2RhVixJUo25HMBr+5XkUxZeBRE9AVgUAtxqb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Od4hR/e1rcazRT5ISx0098gNqui/MjHj+gUp2l0gH7Zamdpm8ProUdjl1CbDc65bZ TaFqDKPAEvkfSU6hcCqWVdCyINLtC4Edh6OqTUYPEE7Bnf+yiYyN0ayH9cDcI8rn8Z W7RNHv4TmUUsAKvuSWtIq6VYaxvZH03d9+jUrpnMwCocdiytOXvw4vO9F1eQCBpG1e sZIi4q4Il06Y4hg90rxzjFHupCm5HSzL6GedFuSDE527kD04GJPytqUw/ShKOzzHk0 QU4TFc6Sz3kBA09CPtbZYm9LtX0Q1yVzndSRfaIsUfjksyUWPnePQRTE4ToJvxdj9f Eu1e9owg/p/vQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nam Cao , Philipp Hortmann , Greg Kroah-Hartman , Sasha Levin , forest@alittletooquiet.net, tomm.merciai@gmail.com, linux-staging@lists.linux.dev Subject: [PATCH AUTOSEL 6.0 18/67] staging: vt6655: fix potential memory leak Date: Wed, 12 Oct 2022 20:14:59 -0400 Message-Id: <20221013001554.1892206-18-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221013001554.1892206-1-sashal@kernel.org> References: <20221013001554.1892206-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 bab08a40fe66..7d9a4000bc13 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -694,7 +694,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