Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5452477pxu; Tue, 22 Dec 2020 18:26:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZ0l1r5pi6tzvjafVes0nz2fM59+McWYuxHUT/enj2eHuk9wzoOldwvIs+3YjtBYFMybNu X-Received: by 2002:a50:fc83:: with SMTP id f3mr23111756edq.219.1608690399293; Tue, 22 Dec 2020 18:26:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608690399; cv=none; d=google.com; s=arc-20160816; b=nqqXOJLKTRYNgYRGW7+RSR+H/tBBWwnRzya+HZWD+0o3U5sxXxvQ9M5TXxfuSzK+kY Trig9poHQ6sp87RJZf2IUdzb1rm2o7BrvtrETWdCfKaMMnjPoROEzE2zCRJEVskDgFdv ORDoXNmOPGMMeaf+Bm1z7lsSy5CM4eJ7MYohWm67PMXCFjD3owAeod6ksDQzw86b6C0U 47xsbA+GCc5ImIoCcdpQy7ONZOenVj0gmD6Bzzb/4zSVvaKmcyyrDMOTvUCcv1j611KA OTiduBWnwCq8GaYube12rmLLin9AFUDctJoHhcocQiMw7a0hgPfXqkwWKVxYr5cpeNHK UHcw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uXb0wx/irPCue6NuRJPMpPNRqmqRXCvZ4H7ndWx/kZE=; b=w2gVG4perz+ofFrlHUGY+qfS7jQwT+uUaNY6BGdWezuj4YPAeFO6W69wgqYrnwUD1r 72MsBPxItQCsNX9fYHT1yT4M4r7pmNQg7coooIESC6ubu4y4Bx+uk21aCp+OaW/TMi3g lXAben5UF7Adv6aH9qx56nCCuZj4n7ouzcCctEOz7wbIeRw1VZ7S2IzZt9h2RyWuNwZZ Vfo2PmohBgQc0WPtuhv1noyXQ1ixk39mfrZ0AtHs/lUaZlvd/7G7pTBEdyrgpmIESZO8 vJiFkhSiTwF5wsRi5OFk2vrvxGg3RCKd3VqxyEbFpgpdcFkfuc7mX28N5tYwDsNsZky1 xN5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=btWFgjYC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si6491402edf.132.2020.12.22.18.26.17; Tue, 22 Dec 2020 18:26:39 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=btWFgjYC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729079AbgLWCX4 (ORCPT + 99 others); Tue, 22 Dec 2020 21:23:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:52452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730034AbgLWCXg (ORCPT ); Tue, 22 Dec 2020 21:23:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C4B9723333; Wed, 23 Dec 2020 02:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690200; bh=7CGrK35cEN11pVpSMg2wMmiuJgUhYG+i/WSrNIA4OIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btWFgjYCqgTZaskJ7AWgJA1h/rdwzDblsD1Ax/NAQvhWtS/BXvp0Jxxch67iFohhS uMFlb2XM2x/SCElowtFM5aeWzH5pxFuwQ6z6CKV5/vb2tCZScMxO/FGeEuLhoWCBgY S2TQF41MvedjHL8cai688m9mgiS74NiB9hJbbGRJXQXTsjEbM46y2+nWR8XiG124Gs cxk9eCCbG7MAxUKu1OLcfKdADlnXAogXlLpzkp0xnFn73cPxAXud2wm5x3emCx25xr n36dEtSp29JBavNXix5wWqvkuUrwMW/13La9dIfkxGmTdHv9IHY2DXsqr+XyxIavWg lp4x4q+AW7blw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 22/66] media: cec-core: first mark device unregistered, then wake up fhs Date: Tue, 22 Dec 2020 21:22:08 -0500 Message-Id: <20201223022253.2793452-22-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Verkuil [ Upstream commit e91c255733d9bbb4978a372f44fb5ed689ccdbd1 ] If a CEC device node is unregistered, then it should be marked as unregistered before waking up any filehandles that are waiting for an event. This ensures that there is no race condition where an application can call CEC_DQEVENT and have the ioctl return 0 instead of ENODEV. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/cec/cec-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c index 648136e552d5b..7c585e05c6311 100644 --- a/drivers/media/cec/cec-core.c +++ b/drivers/media/cec/cec-core.c @@ -175,12 +175,12 @@ static void cec_devnode_unregister(struct cec_devnode *devnode) mutex_unlock(&devnode->lock); return; } + devnode->registered = false; + devnode->unregistered = true; list_for_each_entry(fh, &devnode->fhs, list) wake_up_interruptible(&fh->wait); - devnode->registered = false; - devnode->unregistered = true; mutex_unlock(&devnode->lock); cdev_device_del(&devnode->cdev, &devnode->dev); -- 2.27.0