Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4488627ybx; Mon, 4 Nov 2019 14:15:48 -0800 (PST) X-Google-Smtp-Source: APXvYqwnhXAFgDEbh92W6V7hsmxacTbiAGoet4XOL8Qn1IydNpqJ+mrcE2HNudCCR4e/aSy5jsye X-Received: by 2002:a50:fc1a:: with SMTP id i26mr5381638edr.9.1572905748842; Mon, 04 Nov 2019 14:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905748; cv=none; d=google.com; s=arc-20160816; b=nrcXftz4a7Jd5lgpbd1+BA7Q0LmhcwG0ULGQiI3fHVLbhSQY1gUZJJe+44iaaF75WA 7Lfili4dVU0WpDoghtoFWTgQv7oXtNddaJdSuqdrNu44O0GL4LHkYSOYNram8hH8EYSh g3TM7AB+b7oa9MrkuYKwODUsfh121oHzPvJSK0AA51S+/xc9SYEQa+lsrH4x253qt4UU zAHl6mrcdp8yXrbxOc4GlypYUk8fsp6KTfe9nuPpC3wEtS/WQtzX50U4TpszDtOCrZdS hvR+lWYrD/9alBUdOheOLYDg0VbPRByErqag47uWUD90g5K7x0IzU9xPVe81hbj1pNGZ 5hLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bc1/AdX0HZlXIss3S6rQ+3iLg/PgbCl4QaKcGyUAYfw=; b=tOQLIZqQS0lU1XCKAH8z0/epIoO/72JotbnZLXkKzn3omJUwAQH9aXwW5ohNVz7lwO 6XrA23dYN2v+mI9b1IP9XxHKF3MbzZcbiqI8PqKcRkWUacOr/IyLn0ir4UO049CfZ6eL AvZehpLWf+5xwgj5EA3GNCBTct5wjKMShvarZJeKzxlfUIuauGN5q/0k/9xKRRNSWQpz DB8smn0ybeSqbc+sPXfxs7rdh7CsvWP1yWdymtZTyS21s8ItRsyc8JMpuiAq2Z3+pK1c Osmj+B6FBldZUNU6gGORgvRioY77CEc85kJ5BUJiK9cDlx83S7tfnovbfbNPLQSYYU2Y Ke1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p9TIXF9a; 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 l27si8707825edc.358.2019.11.04.14.15.25; Mon, 04 Nov 2019 14:15:48 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=p9TIXF9a; 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 S2390072AbfKDWHH (ORCPT + 99 others); Mon, 4 Nov 2019 17:07:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:39266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390046AbfKDWHB (ORCPT ); Mon, 4 Nov 2019 17:07:01 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 01152214D8; Mon, 4 Nov 2019 22:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905220; bh=M2HzMP+l+Weo8FPbty/bQt2z8x2v4tAHox0FIemkwwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p9TIXF9a8Y28hMDVnVsvvOwNp1Gtne2+pPEIEYEROGWu6dyVMGYHDFDENzWbNMPyp eoN0k5ainfVDdkl+G2wPhwWJda1rXoLDQi/vdqOx+vR5W6DXG6hV3/OlWfOO2+Wm29 cOackZTvjhkRwDR0EIi1njfZ29I/ETohj06YKgqk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nirmoy Das , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.3 070/163] drm/amdgpu: fix memory leak Date: Mon, 4 Nov 2019 22:44:20 +0100 Message-Id: <20191104212144.991122922@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nirmoy Das [ Upstream commit 083164dbdb17c5ea4ad92c1782b59c9d75567790 ] cleanup error handling code and make sure temporary info array with the handles are freed by amdgpu_bo_list_put() on idr_replace()'s failure. Signed-off-by: Nirmoy Das Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c index 7bcf86c619995..61e38e43ad1d5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c @@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, r = amdgpu_bo_create_list_entry_array(&args->in, &info); if (r) - goto error_free; + return r; switch (args->in.operation) { case AMDGPU_BO_LIST_OP_CREATE: @@ -283,8 +283,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, r = idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL); mutex_unlock(&fpriv->bo_list_lock); if (r < 0) { - amdgpu_bo_list_put(list); - return r; + goto error_put_list; } handle = r; @@ -306,9 +305,8 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, mutex_unlock(&fpriv->bo_list_lock); if (IS_ERR(old)) { - amdgpu_bo_list_put(list); r = PTR_ERR(old); - goto error_free; + goto error_put_list; } amdgpu_bo_list_put(old); @@ -325,8 +323,10 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, return 0; +error_put_list: + amdgpu_bo_list_put(list); + error_free: - if (info) - kvfree(info); + kvfree(info); return r; } -- 2.20.1