Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1138177ybf; Thu, 27 Feb 2020 05:45:25 -0800 (PST) X-Google-Smtp-Source: APXvYqzAgLQbe9paHRD4q0ugpywxCOmpgb7OcE6Ry8k2T2e+KNsUIx6W1+PLZUZc2WVXeVOh+6+I X-Received: by 2002:aca:3354:: with SMTP id z81mr3366915oiz.129.1582811125291; Thu, 27 Feb 2020 05:45:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582811125; cv=none; d=google.com; s=arc-20160816; b=t5Y5YAisYBrbkboV7d8K3etd2hE23Dpatl2GR5hgyDxYVutimtNdvbjsIxBBukxLDa JiBysvzrwPZ4/fLkO/561UIxxP4/A1nCK4u65bROW8vxKkSqG6ikQJ5UxbU7lGiOKauf 9/IDQXTr7hsGiZqMoRFPClN0pOEwFcAsiSDp2FGnzm4TVKzTGzxVrQ+fA286h7Vx0vXp tYRKiVf3M8AQ1WXAznWWANyqLSypUhSEonbC+eM5uBrt26dnfk/ikY8HKThJsrzdKAFm +fgaeIUdeSZ0YFbASqB9Te0R4fcXBoQXQW06D0APc/yjc9us8Mlau6EL/zjUAIVuYiKr FKZQ== 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=EJphQSrXz4FJoQJmtnftS+K9mzRqn6mVXZ+CGSVn04k=; b=Amblw6Ia+wHGAIlGIb1l9CkywjA68rN5/ck1DvSoDhomKlFHVMMJHvGDweDwk6bqSQ IoPRhNtd628sD6s+mZDPvqKBDTu5GvWT7nY0dvxOic7N9vSjupVP849yd+fpPKI89vt2 AetiYEK8IHwYQABEDAz7MaK7Vw4ePpVSnNv+9LJhIVmGxTuU43pGr4Qp4khsrsZW3Gyh tbxUmu9r4qhLM7IKZdRJyyhvag7DDz1NeIeCptQhru3DEBxizUanZ760m40NbqNGC3VH 23eKlqAdxyWJh940mc/JRMd7sUZdmFo7SFgv4dOpWxHDKZ6PMhq2FkVvWwjff9KTUn+1 zhUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dPyQ5Mw9; 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 p14si1695157ota.71.2020.02.27.05.45.13; Thu, 27 Feb 2020 05:45:25 -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=dPyQ5Mw9; 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 S1730195AbgB0NoV (ORCPT + 99 others); Thu, 27 Feb 2020 08:44:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:39782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730188AbgB0NoT (ORCPT ); Thu, 27 Feb 2020 08:44:19 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 070F820726; Thu, 27 Feb 2020 13:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582811057; bh=1ncGh5Rk9EITS77TL+pGGDb/7PSP3K5PnHevgyuW3vM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dPyQ5Mw9z4Wb04y0UyDmtoh9X3WKTYUWHkGVGf+AI/tdqinltvx8s4I+ofFi6tDJH h2PTQRvNokkIQoRemdybVtSYfD2eOBXBQ9pA+Eys8FaxIEabMdRar1B8v68gDVcvkT IDtD+jNOpHwHgaUDeEoF0nLqp1xbVEhhYoyTZ92g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , Thomas Hellstrom , Sasha Levin Subject: [PATCH 4.4 061/113] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add Date: Thu, 27 Feb 2020 14:36:17 +0100 Message-Id: <20200227132221.508306042@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132211.791484803@linuxfoundation.org> References: <20200227132211.791484803@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: 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