Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1932546ybv; Fri, 14 Feb 2020 08:27:12 -0800 (PST) X-Google-Smtp-Source: APXvYqz2hgox7fc8OrCx/vNQ8LX1zfAHdg1Z9Lhhajh04EAyX9R7ACuM1k+DbWYnkvZG6vTAWhfO X-Received: by 2002:a54:410e:: with SMTP id l14mr2410423oic.42.1581697632603; Fri, 14 Feb 2020 08:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697632; cv=none; d=google.com; s=arc-20160816; b=p8qJd3kWYcYxFRtSmc4ZKsvtB4qD3Ys0/Y+fuIjiWWwkAIp5dzm7Ht9LCwgm1s+XKY +CGvTH7QeX26dYtmFmWKavvVaWLOqsRKRje7VUOGZFonaTTCjvuj2UMaVVC02QGInee5 7kWOCKucW/35icmT0sbf0LkNcREdnAMHPQwT7KWn6qBN2nIWBIzKQdF1e+fxlvFVDVTG lt5X0gvHSzwo1UyEhuYWIUQVWULafrUx/PgqH7JoZVV1mHpbHsxMYMCvj7CycpuhtH0h T8mBoYlySk2mLQ+1zmkBpmXbXqY4rJuF15xSysHWYZTqDKfjJgoZUx5NdFrUPQR43fV3 pmhg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EJphQSrXz4FJoQJmtnftS+K9mzRqn6mVXZ+CGSVn04k=; b=WRywbo7s5R0PcuGwBbSaJkCVlJqBym3V32XMxRWVQHfN9aLL0GYFlcyv7VxfsZJ+cs lUl1UAiuSzTZZ7o6HoMB/88Mk4YVNTuGsEtiNC/r0mquhgKS83MorVFk1Dyppusk3vIv WzRYAl8v9EXLcUvjRyhnNhvqxTXGiUWGhPLX0EtNYKXvbWdXkEsxpkfM3nz04a+CnFXw /bdj62tFiGsRuEig5TKZGaj2xoNG7io1aI7LEJvWIqxZ9AooMvdxBv41mBDaU0viKLDj CZbqipM2dV+IATv7vmbd1K7n4vNjUtTRwxUctOQ8O/PwtKRVBZQ1hx28YVBiZXQwyjZE GN6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hXyy75tl; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si2610463oiy.254.2020.02.14.08.27.00; Fri, 14 Feb 2020 08:27:12 -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=hXyy75tl; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406148AbgBNQZe (ORCPT + 99 others); Fri, 14 Feb 2020 11:25:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:59736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405651AbgBNQX2 (ORCPT ); Fri, 14 Feb 2020 11:23:28 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 031C624764; Fri, 14 Feb 2020 16:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697407; bh=1ncGh5Rk9EITS77TL+pGGDb/7PSP3K5PnHevgyuW3vM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hXyy75tlWb4pnMA1c92ToC5bR3NYo+eAeCS8K4KAPQPJaxOHD14yqM48oBr+equjO gUfCH3ZnPlPQ8taaveNVciUWV9B0RODknRAN6l7k5DeGWMYHY8jHkaqsg9DnlOMEeu nkTN7x+IBgAY+VivpCoLRx+l3N/WvAOIH0UY82/E= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Navid Emamdoost , Thomas Hellstrom , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 4.9 100/141] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add Date: Fri, 14 Feb 2020 11:20:40 -0500 Message-Id: <20200214162122.19794-100-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Navid Emamdoost [ Upstream commit 40efb09a7f53125719e49864da008495e39aaa1e ] In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory for cres should be released. Fixes: 18e4a4669c50 ("drm/vmwgfx: Fix compat shader namespace") Signed-off-by: Navid Emamdoost Reviewed-by: Thomas Hellstrom Signed-off-by: Thomas Hellstrom Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c index 1f013d45c9e9a..0c7c3005594cc 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c @@ -210,8 +210,10 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man, cres->hash.key = user_key | (res_type << 24); ret = drm_ht_insert_item(&man->resources, &cres->hash); - if (unlikely(ret != 0)) + if (unlikely(ret != 0)) { + kfree(cres); goto out_invalid_key; + } cres->state = VMW_CMDBUF_RES_ADD; cres->res = vmw_resource_reference(res); -- 2.20.1