From patchwork Mon Oct 24 11:32:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp456464wru; Mon, 24 Oct 2022 06:34:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4slmM7h5s6ZF2y6wUJC3AVJYbxw4vG7Q4EUirSZP93Jtz39+lOKCeCNWsZgu29kunus4wS X-Received: by 2002:a17:907:5ce:b0:730:bae0:deb with SMTP id wg14-20020a17090705ce00b00730bae00debmr28625586ejb.181.1666618454463; Mon, 24 Oct 2022 06:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618454; cv=none; d=google.com; s=arc-20160816; b=Go1U87ChtolmROwupYMHwLmXsU804Uz4UjdWjtIUqjqJ0bBE7vtGk5h9rB1ZWUgi8Q E+l0XNGPx/SoTtsZ6h1qR8gvnrXNyTx4Oes4a7m0NvmeBnNxuVEpxkwTqsSJXBL+str0 jtdho6k30tIV30iotNzfJ3IZp5FSfXSpXwEsTX5kET8dSof6cYL3/hKZUzbN31oYSBRc PALMdoa4KbKhkWw+KhRd0nkEWB3Eie0DawvqkTY0MIk1my0GByEmGTPndqINlym6lMGD lQ84GacEySXWcsZ29AhZ9AYuAx862RGZWlSahme3LV/GH8SjMa1baQ6vJxitJOS3+UTI 2LZg== 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 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.33.42; Mon, 24 Oct 2022 06:34:14 -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 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?1747576112505802233?= X-GMAIL-MSGID: =?utf-8?q?1747576112505802233?= 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); }