Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3786652ybi; Mon, 29 Jul 2019 12:36:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/xHGcE5QygJc510nfTGLQVYc+8c4vGXItYXtfMK97dvzjINVk2oRcIX7vy+YZHQr+Ixei X-Received: by 2002:a17:902:e582:: with SMTP id cl2mr112600499plb.60.1564428974400; Mon, 29 Jul 2019 12:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428974; cv=none; d=google.com; s=arc-20160816; b=ZMeoZX46f/pN5JdCMlJ6DOpqLT9T9zFh9KMNrFpGucpK4eseo8raNSY/eIkY9FVUMD hlV6dWrPqDnzSpWC01CiF9PMU6AfgvtAn8+we/sk2yrLUg2J9yB5PF1ZvwZ/v+nIbNio N9E90bDxiA57tqFI+JuRhjeutWt8oMJ2WES4M+wTggHnQWEFRZSI2Bk5Oq/K1OzxodU1 nfxNRJSKx2sUZZDRdCle/DGN7lx1FJ31JWBwyJ/LQmj4b8rqASqHLNiyvWrG9VI+wtmy rSxxNIe9eTyz9S9D3LoT7RNPkybxMGg9Zqg/d3jbGzvK/RPmvxhWP5FCkuUoiAI2DUEg ceDw== 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=v/JPto70pQu7eWlx/GXaYYbYHLQpj0HGUxgbXWSxv/4=; b=cTA1XK/VxYvCLfjaTzAyXvUokD1t8qk0V48h/VF9GM90ya8H1aE9UGJq7Hz3Eu1ArM YQa7/cDZ8FbzRTZjG3DFDEnEIXorFtpoNrtbgqJ1UbZjAfWysoHBBCTAhXbSYzokkLIn D1X3M9rvNtA3KRbULQZPI+92xYvpLiQZyNSXnYycAOplGieDce4Ltgn+TjDKBmwBXlOi U5Nk6K+dppoNyHLg1Ncm3NHfzFHglJkLS2ECqSblskMEOuXl4VkmjyBuLrbJR02VVErJ XOjKeBDKg/LUVq+vkMcyMvRqSpDi+2Yy0udnVuXnip9XNHCVuXMF4Zp8hysDOPiFE384 9Niw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SDA2ejk4; 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 v24si27562329pgn.64.2019.07.29.12.35.59; Mon, 29 Jul 2019 12:36:14 -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=SDA2ejk4; 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 S2388267AbfG2TeQ (ORCPT + 99 others); Mon, 29 Jul 2019 15:34:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:48584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388245AbfG2TeL (ORCPT ); Mon, 29 Jul 2019 15:34:11 -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 40D9F2171F; Mon, 29 Jul 2019 19:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428850; bh=JTbbLUrqNFcBTWKuNtawhRcJdyH9435aAAWqmKj3o2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SDA2ejk42ePxmcfd6iyh8zRiGAVBFpMOYd3Se2WkppzlRoLYS1916fVlFVFrJJgXP DPxxr7wAbZuqN26XntPlBauxpbYSEhv9EMgUp8PtcwUMEIuyosZz49MtveDbQ7iSXa LsSUk2ykxR05tz8Kb9wXJKayGIphxkdhdsPyEWtk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Daniel Vetter , Maarten Lankhorst , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sumit Semwal Subject: [PATCH 4.14 206/293] dma-buf: Discard old fence_excl on retrying get_fences_rcu for realloc Date: Mon, 29 Jul 2019 21:21:37 +0200 Message-Id: <20190729190840.230106531@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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: Chris Wilson commit f5b07b04e5f090a85d1e96938520f2b2b58e4a8e upstream. If we have to drop the seqcount & rcu lock to perform a krealloc, we have to restart the loop. In doing so, be careful not to lose track of the already acquired exclusive fence. Fixes: fedf54132d24 ("dma-buf: Restart reservation_object_get_fences_rcu() after writes") Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: Maarten Lankhorst Cc: Christian König Cc: Alex Deucher Cc: Sumit Semwal Cc: stable@vger.kernel.org #v4.10 Reviewed-by: Christian König Link: https://patchwork.freedesktop.org/patch/msgid/20190604125323.21396-1-chris@chris-wilson.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/dma-buf/reservation.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -394,6 +394,10 @@ int reservation_object_get_fences_rcu(st GFP_NOWAIT | __GFP_NOWARN); if (!nshared) { rcu_read_unlock(); + + dma_fence_put(fence_excl); + fence_excl = NULL; + nshared = krealloc(shared, sz, GFP_KERNEL); if (nshared) { shared = nshared;