Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp726076pxb; Tue, 2 Feb 2021 16:49:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAXlzNdmicyU2j09M00BkgEbVoX+/ALnDv9assOKwOdBib3HXi5qi0nqptdKZ+TZ3Jwjhq X-Received: by 2002:a17:906:199b:: with SMTP id g27mr567891ejd.405.1612313392789; Tue, 02 Feb 2021 16:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313392; cv=none; d=google.com; s=arc-20160816; b=AJoTzl3eNs0Wk9O8bP2Bouz4HkJXwdHFx/lzuta1t1UKyvPF9OdmbayIPkkQirJHsS hAp+KRBE4Brm0/adEGdwkuMZhVIdbNqtxx4Bym89DENb+WboGT56vYnaphLX+1HVpxK6 b4yvEQiimWXey8OffVI3ztOJZEtEacz6RM8fZFOTaswOAT7ykyzHkWW18LfvW2XoZYP4 RY4YYplTb/6MN7mOWHD2jIfecacHCkACV3U9cQZqToZNIrjPIccfDWVOIXbF8xX95j7S BN+PiECNS4Z5OYAvQhL164gmJ8bT9HJyBDl8pYsl6sTFwuTtt+3Av2Ru/mNOvqzAmA09 fZ0A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mOeE1hEYUIMHjn6nz9vS3Kd+vODlAEvbqxXLEfiDVkk=; b=uCYYGS56Ht0ukklURrL9IKys9qnDpgkJrSkDJUT5MFcCnctfpCoCka5HzlVbTP1fS5 q++PeqIOonSgsTyuvCRTHdCsgiVAOT2fjQ8/d2LkWAeQG5k3l8/Txm/HX1s5lOXqvPCF noVvb6y2Q+9grQ6N3D3hAYuJoCV9ZtmLwY3wgfZlsUpJyq+nYln87bnUPb1kzQcrN5IU GvSzg436o40KIZHu77HcJmO8GC0eyKNcaw7qL5wxRcaJ8jglC+L8xvTpiVS3ep0yMCAm pGW15rrbPVEOTeWZLoHFd1p+N6TlvGNSvdQv3GpcTDvlVCUasfv7KkzVbKyf8rbol/RD poTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yjuF1o8W; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a66si247086edf.607.2021.02.02.16.49.28; Tue, 02 Feb 2021 16:49:52 -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=@linuxfoundation.org header.s=korg header.b=yjuF1o8W; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238766AbhBBUKA (ORCPT + 99 others); Tue, 2 Feb 2021 15:10:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:36350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232818AbhBBNmw (ORCPT ); Tue, 2 Feb 2021 08:42:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 449B364EC5; Tue, 2 Feb 2021 13:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273191; bh=R/JNgvcx5++pHtaSHCV/Ib7M1brnwIVRgTiQHU/uw9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yjuF1o8WwO77k+7PmpjoSofoGiCKCZhK35RnRBs3/MOGhE3Al4ECxwummtZOZvDLz cMwidjQJfhsy/NuFjEMtsFDOayXrJSbP8lWdiG3vhgvtefZeNRjIKRDAm3DWpFb9RE f0+/xKYcRwbEIhxRF6PMRIsDKW8YR39Z/+bLhOac= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Young , Mauro Carvalho Chehab Subject: [PATCH 5.10 015/142] media: rc: ensure that uevent can be read directly after rc device register Date: Tue, 2 Feb 2021 14:36:18 +0100 Message-Id: <20210202132958.334957819@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Young commit 896111dc4bcf887b835b3ef54f48b450d4692a1d upstream. There is a race condition where if the /sys/class/rc0/uevent file is read before rc_dev->registered is set to true, -ENODEV will be returned. Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1901089 Cc: stable@vger.kernel.org Fixes: a2e2d73fa281 ("media: rc: do not access device via sysfs after rc_unregister_device()") Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/rc/rc-main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1928,6 +1928,8 @@ int rc_register_device(struct rc_dev *de goto out_raw; } + dev->registered = true; + rc = device_add(&dev->dev); if (rc) goto out_rx_free; @@ -1937,8 +1939,6 @@ int rc_register_device(struct rc_dev *de dev->device_name ?: "Unspecified device", path ?: "N/A"); kfree(path); - dev->registered = true; - /* * once the the input device is registered in rc_setup_rx_device, * userspace can open the input device and rc_open() will be called