Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1276981ybl; Sat, 17 Aug 2019 23:41:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhLU8DTMelLJErxPTB3H4zAX/znJlPXpdxaJOfAheRMS23+PIWu+6CFtLdb3LJxL2onPFZ X-Received: by 2002:a62:7641:: with SMTP id r62mr17841294pfc.201.1566110509583; Sat, 17 Aug 2019 23:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566110509; cv=none; d=google.com; s=arc-20160816; b=Bcv0u9+1r+XURHPLBa5lrFiSkKXSXZsC/YeuYL2OmcsBHBawd0poizoune99j/d0xM 1bi6LiUE3Dh2nguxjY+Gae6MtG7PHPTmrLZwboXCwyzzhk6lOS3X6bYXNbg4szk1agJj 6ulrhwpZtuvW8dcqwWcxo2ifiIGgG2gKLl7KBsQHeC9fBtHtjJ1pQrch8VofT9N2OfRl Qw5VxkKrMc42L9hlIITghqOE2TOiQWPwT5ZrFTv2twxTmdIjwltuRYES58yUBBRL7YjJ fISCUi0i8TpN36K/nmGdVaN84Y0S/O6QFNCUr+osZK4XnnCpdLEuy1HXIVbFwZSL7kPO CaJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=NQ/5tyRI3jdXbSjfHy7ZyjCm7NzWYQeUYMxyiQB6M1o=; b=BXzE5xykpSZu6o2RsL9dXn46FiD3ll/WM7lGbXF5S6DxxnEM1k8HHH4Rj369XyoXu6 R0vJuM7p2cLHNz4rl6xylNIkx6tdDuoH4bTREoviAO9Txf+d6fw+vvLEbkWuachtJuGW EmWedtSFgveLXvQBEN8zvG7d4lMF4pJ3hfxcyn6e7mLzs/qYCqGLLNOBQd3fWXFuBfmD Y1pYkJaQvIxp0U9sMlpyFp9tYEjB0cBR5Z5FWAsuWAIPJqODlgrGC9d+EqgKUGxpkWYw h4gDX65YPTmr0dn6U00k5QUD/ClmkjJ1dH3AWJrEhKzxQHi64fZWJ44lQfYtz4RE4des batw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10si7376242pls.385.2019.08.17.23.41.35; Sat, 17 Aug 2019 23:41:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726533AbfHRGkK (ORCPT + 99 others); Sun, 18 Aug 2019 02:40:10 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:40248 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725786AbfHRGkK (ORCPT ); Sun, 18 Aug 2019 02:40:10 -0400 Received: by mail-yw1-f66.google.com with SMTP id z64so3128690ywe.7; Sat, 17 Aug 2019 23:40:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NQ/5tyRI3jdXbSjfHy7ZyjCm7NzWYQeUYMxyiQB6M1o=; b=l7ilRmV6p4oCxqL3EmBI89oNvUWejzBTwy8wIgRGF+iDDgKPl+/o+IJCE6cAzB8yv/ 8t3N/uLbQtnz7bTVJclE897WmA2MDMzDAgGV839hIpHvmP/sevMXnUtym+XYSlqISxx0 GhrpIhYWOp15jH96S5KKSUvjje6ulmgKRosXgg2VHH9yotDsPOR67StEPkPZ/xpRsLFd ZDmrV0BL/RbyqR79CLaJxHY7dD3wgFfYyeSw46Uc7GLigZ6C9KOeCHyy+G7sD3gYjFdw l/7JgjBoeJR/pOqCt5uE0mx3FtWBz7VpSrRYvXQOYsx9zVegZByBrHmGKwuYPXPkyAjZ L0ug== X-Gm-Message-State: APjAAAWTSmhBPuT0q9oZpB/orYD0Tl7FxCTIAnSlSN0fN8pJNHYqX2aX 2BCrcMMwRogYMjznHFWTZNQ= X-Received: by 2002:a81:5f82:: with SMTP id t124mr12559223ywb.513.1566110409630; Sat, 17 Aug 2019 23:40:09 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id r19sm2801463ywa.109.2019.08.17.23.40.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Aug 2019 23:40:08 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Benoit Parrot , Mauro Carvalho Chehab , linux-media@vger.kernel.org (open list:TI VPE/CAL DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] media: ti-vpe: Add cleanup in vpdma_list_cleanup() Date: Sun, 18 Aug 2019 01:40:04 -0500 Message-Id: <1566110404-3900-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an error occurs in this function, no cleanup is executed, leading to memory/resource leaks. To fix this issue, introduce two labels to perform the cleanup work. Signed-off-by: Wenwen Wang --- drivers/media/platform/ti-vpe/vpdma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/ti-vpe/vpdma.c b/drivers/media/platform/ti-vpe/vpdma.c index fd37d79..53d27cd 100644 --- a/drivers/media/platform/ti-vpe/vpdma.c +++ b/drivers/media/platform/ti-vpe/vpdma.c @@ -445,23 +445,25 @@ int vpdma_list_cleanup(struct vpdma_data *vpdma, int list_num, ret = vpdma_map_desc_buf(vpdma, &abort_list.buf); if (ret) - return ret; + goto free_desc; ret = vpdma_submit_descs(vpdma, &abort_list, list_num); if (ret) - return ret; + goto unmap_desc; while (vpdma_list_busy(vpdma, list_num) && --timeout) ; if (timeout == 0) { dev_err(&vpdma->pdev->dev, "Timed out cleaning up VPDMA list\n"); - return -EBUSY; + ret = -EBUSY; } +unmap_desc: vpdma_unmap_desc_buf(vpdma, &abort_list.buf); +free_desc: vpdma_free_desc_buf(&abort_list.buf); - return 0; + return ret; } EXPORT_SYMBOL(vpdma_list_cleanup); -- 2.7.4