Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4161307pxk; Tue, 8 Sep 2020 12:14:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGxOA+JyLepiqbIUKzMKQ/Q5Cofc7MzzbuF26pT+wkZ4Bj5uKUoiNvhqt6YDlvj7d8c/m9 X-Received: by 2002:a50:d802:: with SMTP id o2mr536491edj.152.1599592484030; Tue, 08 Sep 2020 12:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592484; cv=none; d=google.com; s=arc-20160816; b=elozuLfgPfc3GUBoZXxsF2M4edIWyuxXfBBuCYCxJWsnw7sy3CHLVLjzZG549ItOTe BnbbdstSGdsBsVZ1AkShJiaLGS9lTaRU6PKcJ4acc0EF+C0yVfggEwSkeGXz7aT1MLF5 nd7RApR35jnVHHDw9oMhmdFme2zze5GVtsEzvLeOYF1MkXw7NMN1KUl7SJBWFGb/9aPg 6yNmAu4ae3j96PM2xKfE3A7D1vW5ZkiVgYlHPzpmH8VR8MA50RT9T1QkEkHBEPpkwrsF reGL7KQAmNhiIAw6F+4wcU15FGAQCVxl8EEvKJw8tls4wqYz945UFru1w9mxf7M3Bcsr K0TA== 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=KCLJPhh/VSZPEKHhO+2ZzviFgBmpTR8LuEj/S5KaSuU=; b=H2sbSaiS6WL6ZxD6kY8YUw3XpGbh8FwInjV3Q+hI9lPW+Dn9AIBWOrxoLGg2DAsn/h 1uWxRuqmDiX/P8Z06DI47FsyW8QvhsaZgaJbKx0Crja0Df4fO6bdTV0w5Q2loHYgNAts Zxlj0imKPYB9aY6sZgURDdCeZpsTei3eHI41Zrsea+5/ejwQxt5KIFDAu38ZHUC/V2zn AUZr+7WlAe56i7jhZwVShs2ZTgp5rCZK125nLWq2HHzzoCNF/9VGPnNy5MseaQB/+GgM xEdLBxEW0jhQWz9Mgvs8DWG7XOudsHYCdWleCYAbsFF5KFQMFlj6A/49MYw4/TnmhcVA LvfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VCQyvzSZ; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si11774398ejx.16.2020.09.08.12.14.20; Tue, 08 Sep 2020 12:14:44 -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; dkim=pass header.i=@kernel.org header.s=default header.b=VCQyvzSZ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731731AbgIHTKv (ORCPT + 99 others); Tue, 8 Sep 2020 15:10:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:51452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731228AbgIHQFY (ORCPT ); Tue, 8 Sep 2020 12:05:24 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 2770F229C4; Tue, 8 Sep 2020 15:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579966; bh=NqMaoRw+5/BsIKvTRlZSxaEi2PjZWGU9pYqi2JqcjVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VCQyvzSZTngePZrtJTSrJ2+si+OXoi76GMDb8jr0h4uCQ3nkLtoVAOgv7N09Ve6u9 mZUdlhWVbXIVb9I3cA9NhI1lCDoSwZAqW198mFpo9Qw2faXqUhwZOeVbgOM1HAJKke 1lPawg0ohyn42hZirYD0f/b6XJzR9G57DteqtOSc= 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.4 104/129] media: rc: do not access device via sysfs after rc_unregister_device() Date: Tue, 8 Sep 2020 17:25:45 +0200 Message-Id: <20200908152235.032347423@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@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: Sean Young commit a2e2d73fa28136598e84db9d021091f1b98cbb1a upstream. Device drivers do not expect to have change_protocol or wakeup re-programming to be accesed after rc_unregister_device(). This can cause the device driver to access deallocated resources. Cc: # 4.16+ Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/rc/rc-main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1256,6 +1256,10 @@ static ssize_t store_protocols(struct de } mutex_lock(&dev->lock); + if (!dev->registered) { + mutex_unlock(&dev->lock); + return -ENODEV; + } old_protocols = *current_protocols; new_protocols = old_protocols; @@ -1394,6 +1398,10 @@ static ssize_t store_filter(struct devic return -EINVAL; mutex_lock(&dev->lock); + if (!dev->registered) { + mutex_unlock(&dev->lock); + return -ENODEV; + } new_filter = *filter; if (fattr->mask) @@ -1508,6 +1516,10 @@ static ssize_t store_wakeup_protocols(st int i; mutex_lock(&dev->lock); + if (!dev->registered) { + mutex_unlock(&dev->lock); + return -ENODEV; + } allowed = dev->allowed_wakeup_protocols;