Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7490580rdb; Wed, 3 Jan 2024 19:28:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfuqorIC75GfCWbuzHOWEI9+PdgZpyabzxuAmuEcaVyIaQJoZqU/YjgctYQbwWHGn39SjW X-Received: by 2002:a17:907:7e94:b0:a28:1f75:86a with SMTP id qb20-20020a1709077e9400b00a281f75086amr1652604ejc.85.1704338924208; Wed, 03 Jan 2024 19:28:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704338924; cv=none; d=google.com; s=arc-20160816; b=rAjTaasI0soN6ktwW1uD7A8V3uWLN7lapb1JsRrJg/HUb3yAVenGJ1Ufty2HIvo+dP UYc2zlfstyE+HwTRG1FUAkwLr6+GRyZgSMSrTQd3kvakndDBCiFA/tM2EUXUH6zH5DoQ MdhioXVEMhrp/1rz/TuorGRn0WiOqNPAC0FKa5vLct41Sqcy06sD3076Kp9fgMdldzaW Ct4fSGQNJFcNTsT+W1ZEDt3O5P9M8+1D7X3GNnHOOJqXr/4L0IwBlBYJktlN3AiHNPQ2 FA7E7oAoHwYiXaBe4QyGXlnKI8llRmXcCzIqFQjCgZfZMoDqX8k5sYOWDhIGhb5H0nfq N2/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=RjJhlRJd8IebV/Ux2jUleGgIAnCSP1JZTISPsPLyWy4=; fh=dvn9Nun5YH4kX6duVH8+o7Bcy+2z5ziXByvpFLWFbuU=; b=GC7TVwjLzOMvlK7TOT679GgIFuJLzUJI1ZdDwjP/LnyHJGoytC9zokrw3Alf+gNAiF g5tMt94CIXanAHPjwl24d1iokJ00fY75P/Y7BpAsOuSKsb9PaycFHTjJRYkYPUK342Bd C9Wfu8VANb6qenXMoohMdqitp7Zkf7nd0EFxStsZGw2Kf7aJLs97MCWRJhZ3hyqtCEHs ygVI0W6YyjwdMdYknpWOlqtjDiqHvBjq6yLIli41wZs8EZc8S73AwtmsZ+u/wjxDcB5M m6TYLIuWyPe8zigjYZtu57TmPCgkNeGjjenxA0mFVyff2LR0pfBhm4ORM+biWrEP1Rje V7DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Dsbbhvd3; spf=pass (google.com: domain of linux-kernel+bounces-16226-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u6-20020a1709060b0600b00a28c9e36b45si408959ejg.571.2024.01.03.19.28.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 19:28:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16226-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Dsbbhvd3; spf=pass (google.com: domain of linux-kernel+bounces-16226-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E04B51F25F33 for ; Thu, 4 Jan 2024 03:28:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E96F5678; Thu, 4 Jan 2024 03:28:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Dsbbhvd3" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D6EB523D for ; Thu, 4 Jan 2024 03:28:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-dbd7248ac28so89096276.2 for ; Wed, 03 Jan 2024 19:28:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704338914; x=1704943714; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RjJhlRJd8IebV/Ux2jUleGgIAnCSP1JZTISPsPLyWy4=; b=Dsbbhvd3kSNjdq2vFiy+EC51h1sbB03IF3qSE92WW5QGwvcktf6kPqBGuD3M/tbRbq aJVy+6akzT3JFjruPQJPuYN/i0XaMQ+eNeE4lNp/caTSHKlgwGGuNumWbauBvh8bhPym l7wU6F6sdBpPXiOPXnoGg28HyoikYmuQmzu/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704338914; x=1704943714; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RjJhlRJd8IebV/Ux2jUleGgIAnCSP1JZTISPsPLyWy4=; b=DmFUcrvW9IbbMPgirVUrO/RVxUy6hrSFqAAs2hKtT6QwyfPm3t55plu3fBFYnvLk2t ajtAPNLmncmcXQ2aXaeeXm1nXkmK6MjfMz6oVUwZeoUyxCm5DYAYZc990ltnDvXSChpS A0bLjqJRp1Z76sbg31cjtI7xj4SRIN7ccztKV47FO1acKSHq9NQ5aZDOb9CUv+HkJc2w iCECWuIu3POy1a+UtCkj3SZs9vWPZg+fdyu4QVyCFO4GHRH40oJrX8m2iWoRTDrNsAWp 5kXXp7Fp3FnDbKklwNFpaApsJKpnGH7q7maFgXPOyYDJEvboIEoD9ZyGOeKuW2Z1rLgr 8cVg== X-Gm-Message-State: AOJu0Yyo4S0TpYVs82SbVp2v4wQ3Gnm/hYgS15MHdtUA6m56p7Q8CLpC ZHyBBnIOUyq+/iqBTtPoZuedMBaLqfP3Rl4TwXe9a48brjt5 X-Received: by 2002:a5b:8cc:0:b0:db7:dacf:3fc6 with SMTP id w12-20020a5b08cc000000b00db7dacf3fc6mr15131ybq.115.1704338913905; Wed, 03 Jan 2024 19:28:33 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231204091416.3308430-1-alexious@zju.edu.cn> In-Reply-To: <20231204091416.3308430-1-alexious@zju.edu.cn> From: Zack Rusin Date: Wed, 3 Jan 2024 22:28:23 -0500 Message-ID: Subject: Re: [PATCH] [v2] drm/vmwgfx: fix a memleak in vmw_gmrid_man_get_node To: Zhipeng Lu Cc: Zack Rusin , VMware Graphics Reviewers , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Matthew Auld , =?UTF-8?Q?Christian_K=C3=B6nig?= , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 4, 2023 at 4:15=E2=80=AFAM Zhipeng Lu wro= te: > > When ida_alloc_max fails, resources allocated before should be freed, > including *res allocated by kmalloc and ttm_resource_init. > > Fixes: d3bcb4b02fe9 ("drm/vmwgfx: switch the TTM backends to self alloc") > Signed-off-by: Zhipeng Lu > --- > > Changelog: > > v2: Adding {} to correct the if statement > --- > drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/= drm/vmwgfx/vmwgfx_gmrid_manager.c > index ceb4d3d3b965..a0b47c9b33f5 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c > @@ -64,8 +64,11 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_= manager *man, > ttm_resource_init(bo, place, *res); > > id =3D ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_K= ERNEL); > - if (id < 0) > + if (id < 0) { > + ttm_resource_fini(man, *res); > + kfree(*res); > return id; > + } > > spin_lock(&gman->lock); Thanks, I pushed it to drm-misc-next. z