Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp472511yba; Wed, 15 May 2019 04:45:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4sadxaLDKutrk+o4Z/Memq4fgRPpvRyoBgIMYakF5xEovBzBa0mHBMtfyXEIGyRQwv2pG X-Received: by 2002:aa7:9dc9:: with SMTP id g9mr9795797pfq.228.1557920700176; Wed, 15 May 2019 04:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557920700; cv=none; d=google.com; s=arc-20160816; b=emteaiPE66M3vq2l+gt4q/ehj4tbKlZBCNKMONOE+orODRIENv9a5Jhw3vW3lKvSMt ee8xVeQPuMbV9Enh85aJxvm3OHYzvLOzoq4TKrrlNtkk+VQNd9Yb8b2IagV2jVAC1OIv 3tDD8u3thxljTUn03NeBjY/DX9CFcQbqlgfNGBvvwNfb7FhAqd0cYLRHo813QgvHAyCx 5YEKKyXbcDF3XL0qmZ/lmqSOCJ0u4KZWIZ+LFBOaI5U5wzXn4LKfi/KGJviX2aAzdabz APS6gMYqfHKTEfWZw9H4wIJZsVg4RYunRxt+DEXvjr5rXjPAlo9j1htmXChCkfxSJzSQ Oadw== 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=6yZTpxFurYxvDIONcahtKjD9RVm42wUY0FGowVogMwA=; b=t6B4J0y9DT5UDheilIv2DY25jJ2qe4gilFWI/9kaoj+7CvUd+pHD9T5xXwg+mdMa7V Ogdv0uLL8bX4eBi7aGRc/axOFsTkrTXwpvMnMt03lrptvIZeeTI9SwUfN+kEtd4HSSGh vMaV0rFRu3FA41qP7E/S+RIVXVhFsp2vUjZwcjzDlZ8uYACQjYR4qATdHIT88pQPoj8f l9165a9NB8Et44K3PjbSgXU0dJ5YWyljtGTBfFVflVt99QRnTAKLT5e9xtdDv7FiJdU5 2H0Lwf1tVCjIvxf+Zgj7LqtLmEJOHkuFcTRSllcLsEE775Gz5cCxIEjzeVwLOW6lZSTk LE2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vEg98YSQ; 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 b70si1898476pfj.166.2019.05.15.04.44.45; Wed, 15 May 2019 04:45:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=vEg98YSQ; 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 S1732583AbfEOLmX (ORCPT + 99 others); Wed, 15 May 2019 07:42:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbfEOL2M (ORCPT ); Wed, 15 May 2019 07:28:12 -0400 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 0507F20881; Wed, 15 May 2019 11:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919691; bh=clui04QC4t4n0r//6FAgmXuRtDJsSv/oVvcDZ/NpBYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vEg98YSQ3qR92SdS9BNQ7lsehbbaXJwzVaXg7bxb3y70+IxCKY3QGBWP9I4I36k/a jn9N4/rBPODeY3EqWX6WIB7XmMxNm/0NEHAHlzva6WCelJac7r9qTLd1/s4nTi3vHT jP528tCtKXxyzqy/w6lprAvnKdRyWgDcphXd3LUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lin Yi , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.0 030/137] drm/ttm: fix dma_fence refcount imbalance on error path Date: Wed, 15 May 2019 12:55:11 +0200 Message-Id: <20190515090655.492579941@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090651.633556783@linuxfoundation.org> References: <20190515090651.633556783@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 [ Upstream commit 543c364d8eeeb42c0edfaac9764f4e9f3d777ec1 ] the ttm_bo_add_move_fence takes a reference to the struct dma_fence, but failed to release it on the error path, leading to a memory leak. add dma_fence_put before return when error occur. Signed-off-by: Lin Yi Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/ttm/ttm_bo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 996cadd83f244..d8e1b3f129046 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -881,8 +881,10 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo, reservation_object_add_shared_fence(bo->resv, fence); ret = reservation_object_reserve_shared(bo->resv, 1); - if (unlikely(ret)) + if (unlikely(ret)) { + dma_fence_put(fence); return ret; + } dma_fence_put(bo->moving); bo->moving = fence; -- 2.20.1