From patchwork Sat Oct 22 07:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1111039wrr; Sat, 22 Oct 2022 01:55:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AzxLVZISYO6SXUGcArPhIJVHjiEm1uTKrahNY/3zbDOwBEQOCUApW+Kr6QTdeSMt3lbbo X-Received: by 2002:a17:907:6d9a:b0:7a0:d2d9:31cc with SMTP id sb26-20020a1709076d9a00b007a0d2d931ccmr2018783ejc.747.1666428943652; Sat, 22 Oct 2022 01:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428943; cv=none; d=google.com; s=arc-20160816; b=kOfBaGcJLAqt2Lgm31PpBm+a6DjMAA6c3N0U4VFl+NDu6dQ3LMOHdKPQNiG2ryydGV RLfwDPfOQ8D31QK62tvKNID/RmBsjiny7KII4me/d02JtZQeeGKYZy1rDQYPHWWQcj8/ Dukhs74EulULgKLRStDcF6V2wcxzXPZ6b2QzCQN37lYMoOHPg/59UJu+S7smMToJqjWe oEhRU9dQp52hPaCK+cjOYW6LiUq0jU9BZzVNWC0zeahDRtzXDagwerIaZysMEEV/ozId HsToyRadsLRRv9Mh6F8h8x/ezmt1KK6m1sLgw9qSAb1q7Suq2G503wRzXEqpSPk1KeTr F1jA== 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=y+7SeGmAR1knAc1kQp0LMed0dnmeTwiDcUIDxNFVKA0=; b=Xu0Pv3q9bElLfXPmoCa5h+6KUPiBLyAvG4reNyx3kDRI+Yo1tMi8cWN61RvpJepwgK MPF0XZZ5Z9c0hUBZgBynfNQ0yGV67ph4cdYBLzAipmyoYxcqW4qgPzKkNe/ARd6rKEDd l320dj3aogPqR7QNPzU453JGbLgRg7chCBz3SEp0QHUD1MZFFvj97jQvOWirJDHNSx7P b21gZWL7yrHiy6RXadEIBoz7wGDLHmlvyCkGuWZMrbzXkF0t5ezPLfQLBlb1eFdPkReF yxtNsC/FuN+VlIN26uhtwbHkHcgAykg1A6oxWXbc3CCqUGtO/egtvLJrrxtjPSiutCDD S77w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qFuhRjOB; 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 hq4-20020a1709073f0400b00791910ecd0fsi19494879ejc.540.2022.10.22.01.55.19; Sat, 22 Oct 2022 01:55: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=qFuhRjOB; 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 S234932AbiJVIxj (ORCPT + 99 others); Sat, 22 Oct 2022 04:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231858AbiJVIwu (ORCPT ); Sat, 22 Oct 2022 04:52:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DCE1635E1; Sat, 22 Oct 2022 01:12:26 -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 C193660ADF; Sat, 22 Oct 2022 08:05:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8A8BC433D6; Sat, 22 Oct 2022 08:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425934; bh=D/w4+tNdgXpjzCLigmMkqIOrd6AKbniJcwUCMTZWcE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFuhRjOBeBpBC3+lEN36tYhWEpqJQEK8Fiw/uffV9/qnb8giRZDULmIzwShC0KswQ ZqjztbUi0QUiMRhi9BXJkk2ycOeQ9Igo35jMf+px1esNuF0uWadhcWo0zB4y+tV1O3 8qPH7saBSMMLN4jSYxoJDiN8lpypla6ow8pKuLMI= 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.19 664/717] staging: vt6655: fix potential memory leak Date: Sat, 22 Oct 2022 09:29:03 +0200 Message-Id: <20221022072527.766676824@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747377396082999994?= X-GMAIL-MSGID: =?utf-8?q?1747377396082999994?= 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 ecb8c3934bc6..a91c834c96c0 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); }