Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1130604pxf; Fri, 2 Apr 2021 01:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO9YD1hAUpSOJpa271vLJUhKSTs5mFzALkdyizE4soDu1ta8gJy87QWTeT+HCHnJvS0BmN X-Received: by 2002:a92:4b05:: with SMTP id m5mr10847425ilg.188.1617353827781; Fri, 02 Apr 2021 01:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617353827; cv=none; d=google.com; s=arc-20160816; b=SiccuxLwradi55Ne2BDfeXo6W5snZEdLR2CuW9V8lk4m4ZlX3KsesYoJHKB/2qI8Ko /xT5zxsX5JuD57KONTprEJ1F6BK30tFRxNM4mE2tFWnH/mpduzFLXfPWgKKiGT4zPnyt Kdid2hqPmDesOQf6RbP2enoNeuQpb5ZTMe7TWnUEMPOomTPKFUrPj+LrGwgFtw8JmNvn y7f0dB64gQDLN6G17AhnQYaAJv/EWLkirxqBCwjWmZXDmNEN6dVbthSApybetG52iN1W 8QgLBP8h+JCtWkbCbB7wZq1X5UZVnFCha49EvachZkIJ8gl69xX0bijGbSQiSLByHR9k alHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=P3i44EKsVQUlzGGJeJdRexS0novQjkgiXRmKa0x7ToI=; b=qMgxs3u0NhUpFD6K0BeUYZw7fkHIyOjazx6QpRJ/LGeGAfpVRMZUK9R67p6l3+lx2V bvPv+zbN7xg1sfOy/fxWRD3Z2yb7Id1vHZcsU3c2xL+h/HehacFrPNYK4sKKKj3U0qhZ A/tH+tvn4SgN/3xHQiZW40pPBTyRmrCRNYfDoVVbkSojGWaBpEbwesZQ9cy6Vxt36Hm7 CbS09AE2ThkKSycbZGioT+1D+kntN7CgR+CvdY9Uo8sj7IlOTEFwpkLdR9MPiyJswU1r sPeuuHRGi+KoFLAIk8gpFlf52Zm1Cv7R1gHkneAWSyh6gfMNC5ww7+/Q34YQ5cnRF7nb WXjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u28si6983795jaq.75.2021.04.02.01.56.54; Fri, 02 Apr 2021 01:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234488AbhDBIz4 (ORCPT + 99 others); Fri, 2 Apr 2021 04:55:56 -0400 Received: from mail-m17635.qiye.163.com ([59.111.176.35]:59524 "EHLO mail-m17635.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234479AbhDBIzx (ORCPT ); Fri, 2 Apr 2021 04:55:53 -0400 Received: from ubuntu.localdomain (unknown [36.152.145.181]) by mail-m17635.qiye.163.com (Hmail) with ESMTPA id A3C5F40010F; Fri, 2 Apr 2021 16:55:51 +0800 (CST) From: Bernard Zhao To: Ben Skeggs , David Airlie , Daniel Vetter , Lyude Paul , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Bernard Zhao Subject: [PATCH] drm/nouveau: fix potential abnormal lock/unlock Date: Fri, 2 Apr 2021 01:55:47 -0700 Message-Id: <20210402085549.77050-1-bernard@vivo.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZTkpITUkYTh1DSB5MVkpNSkxITkhMTkpCTk9VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS09ISFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MRQ6PRw*ST8UCipKDTgCCQ81 ThwaCQ5VSlVKTUpMSE5ITE5JSUxDVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlITVVK TklVSk9OVUpDSllXWQgBWUFJSEJNNwY+ X-HM-Tid: 0a7891cbbd49d991kuwsa3c5f40010f Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix coccicheck warning: drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c:115:3-9: preceding lock on line 109 drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c:98:2-8: preceding lock on line 95 As we see, function nvkm_fifo_chan_inst & nvkm_fifo_chan_chid both use spin_lock_irqsave, but no spin_unlock_irqrestore in if/return branch, seems like a potential bug? Signed-off-by: Bernard Zhao --- drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c index 2ed4ff05d207..e3f624d97644 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c @@ -95,6 +95,7 @@ nvkm_fifo_chan_inst(struct nvkm_fifo *fifo, u64 inst, unsigned long *rflags) spin_lock_irqsave(&fifo->lock, flags); if ((chan = nvkm_fifo_chan_inst_locked(fifo, inst))) { *rflags = flags; + spin_unlock_irqrestore(&fifo->lock, flags); return chan; } spin_unlock_irqrestore(&fifo->lock, flags); @@ -112,6 +113,7 @@ nvkm_fifo_chan_chid(struct nvkm_fifo *fifo, int chid, unsigned long *rflags) list_del(&chan->head); list_add(&chan->head, &fifo->chan); *rflags = flags; + spin_unlock_irqrestore(&fifo->lock, flags); return chan; } } -- 2.31.0