Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp332283ybi; Thu, 13 Jun 2019 17:12:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgC8MsZt6LYjorMSjeca3Re1dOlbKmnIvAfoODMdEwVOj0B6yXKVXf6g3d68Af8CANA7g3 X-Received: by 2002:a17:902:aa0a:: with SMTP id be10mr83834994plb.27.1560471146839; Thu, 13 Jun 2019 17:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560471146; cv=none; d=google.com; s=arc-20160816; b=zLW99eKyMYP9a0zrD1CQSHZh/9rJshdrLX8Anyr8BgcyzIdAZux6U6YmQ/3xYkbIrp oJIWofvV87Oxs+/F06eU6HDZp1QBkhJhIr6Yq+acjrNeylkNpQmzYdmSiHei+AB0ZziC M9vsMYXsyDjOCTtLC/9UwLIzyEfD8wf4UvNcglRv+LqyIxSpNXSwoJKjLHvxOKj/2TMv z+pry6wDHleyLP5Y4tvZ4RB+nolGppcSLFUDGY5lSy14rd1aqfHaKQloOJuHwW60H/cM wUuEsPbCAsr8yB94iBSg/pQfGNTq8J+b8UsUJagLYTJiA0lw4iVXeE0Nnym+oW188eux lumg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=2rNJ7DTMjMPhOlVosuT+dcn+kIR1ESSVOR99OmM6ZKM=; b=N31NaiDPGTFsZ5VnZenfZd5g9ycp7bnGEVe8wicgZrj1nu0KDyHOlq2sUA7YGmO6GY /T7xbzm7MNRbIYHXWWxiYObAEL04F08G6IyYz98D5EQuliw8v9r2VZBKbsN9lvSeCXf+ NCjKhv6UQojDNcqrXM8hwom89BSCL/FnF82Xw5pqV9zZfFk+f+DJGi6agu+X5YVV9+gJ iJn4+131+PUYxRzq6MndqzQNxIHqVG87IUAUVzrhlj1mWRQoCTb/CqMz+lqxXsDIlqI5 dUpeFQtiVM74QQ69aFvrRvAbUxY2PfSsvTkJJn7Qpyp4DVjsTOLUU35bfHHFwlvnR2PY kIqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=neN3kBOM; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si742475plo.297.2019.06.13.17.12.09; Thu, 13 Jun 2019 17:12:26 -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=@nvidia.com header.s=n1 header.b=neN3kBOM; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726187AbfFNAMG (ORCPT + 99 others); Thu, 13 Jun 2019 20:12:06 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:18268 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbfFNAMG (ORCPT ); Thu, 13 Jun 2019 20:12:06 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 13 Jun 2019 17:12:05 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Thu, 13 Jun 2019 17:12:05 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Thu, 13 Jun 2019 17:12:05 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 14 Jun 2019 00:12:04 +0000 Received: from HQMAIL104.nvidia.com (172.18.146.11) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 14 Jun 2019 00:12:00 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Fri, 14 Jun 2019 00:12:00 +0000 Received: from rcampbell-dev.nvidia.com (Not Verified[10.110.48.66]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Thu, 13 Jun 2019 17:11:59 -0700 From: Ralph Campbell To: Jerome Glisse , David Airlie , "Ben Skeggs" , Jason Gunthorpe CC: , , , , "Ralph Campbell" Subject: [PATCH] drm/nouveau/dmem: missing mutex_lock in error path Date: Thu, 13 Jun 2019 17:11:21 -0700 Message-ID: <20190614001121.23950-1-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1560471125; bh=2rNJ7DTMjMPhOlVosuT+dcn+kIR1ESSVOR99OmM6ZKM=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: MIME-Version:X-NVConfidentiality:Content-Transfer-Encoding: Content-Type; b=neN3kBOM4fwFzxxjmxWL1ltp+tFO8bAcbqFK/NkF6ljwaGDjCyCUNjyfFcYeKG9T4 5LdGR7QCJzezPlMCmrdKYb1uNBS/iIAEnpK1hMJVC4YlXEsNnr9L2qFHaYil+aBIyJ 60wMyDHM5XN/zwZxTsCkESQujXLaoeWvhG5kKgnBZubuDk3cxpKMsqfWLQComwBkgO y8MOe90H/Rqb7zeWBsQG5hqIu9N7CqlNp/FIgtnz3xiNXN0ispWt/+exKroPpJ9wCJ Pz57q/vucsb+GtG/qX1XENQ8dZu+F/CYr0G+CV/G3g2ekKciae45Ha0N3zk6j+9N+U gbTCIFIddddug== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In nouveau_dmem_pages_alloc(), the drm->dmem->mutex is unlocked before calling nouveau_dmem_chunk_alloc(). Reacquire the lock before continuing to the next page. Signed-off-by: Ralph Campbell --- I found this while testing Jason Gunthorpe's hmm tree but this is independant of those changes. I guess it could go through David Airlie's tree for nouveau or Jason's tree. drivers/gpu/drm/nouveau/nouveau_dmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouve= au/nouveau_dmem.c index 27aa4e72abe9..00f7236af1b9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -379,9 +379,10 @@ nouveau_dmem_pages_alloc(struct nouveau_drm *drm, ret =3D nouveau_dmem_chunk_alloc(drm); if (ret) { if (c) - break; + return 0; return ret; } + mutex_lock(&drm->dmem->mutex); continue; } =20 --=20 2.20.1