From patchwork Fri Aug 28 12:06:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 264856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C803C433E6 for ; Fri, 28 Aug 2020 12:07:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5646F208CA for ; Fri, 28 Aug 2020 12:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598616430; bh=R3tRmH34YpUQb4GzkyY2/LySerisO73sPy1IbIR16IA=; h=From:Date:Subject:To:Cc:Reply-to:List-ID:From; b=JBr/J+1m6f4j4Z+dxDa4+CHrhYcmcTDkRaPluQnlGmzDvW8XKSeB4PKTXVxeAyrS5 qxp8z12rpl2QKS3ijumPN8TnBrSLmWHyV5DRP5fkptyb1OchmhPQnuopO/J9zjXZdk dW+qfapJx9dNcqCNjrQFb6bKB/MCE5gc0BtUVM3Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729195AbgH1MHJ (ORCPT ); Fri, 28 Aug 2020 08:07:09 -0400 Received: from www.linuxtv.org ([130.149.80.248]:50734 "EHLO www.linuxtv.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729171AbgH1MHH (ORCPT ); Fri, 28 Aug 2020 08:07:07 -0400 Received: from mchehab by www.linuxtv.org with local (Exim 4.92) (envelope-from ) id 1kBd4F-0055dN-If; Fri, 28 Aug 2020 12:01:15 +0000 From: Mauro Carvalho Chehab Date: Fri, 28 Aug 2020 12:06:36 +0000 Subject: [git:media_tree/fixes] media: rc: do not access device via sysfs after rc_unregister_device() To: linuxtv-commits@linuxtv.org Cc: Sean Young , stable@vger.kernel.org Mail-followup-to: linux-media@vger.kernel.org Forward-to: linux-media@vger.kernel.org Reply-to: linux-media@vger.kernel.org Message-Id: Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is an automatic generated email to let you know that the following patch were queued: Subject: media: rc: do not access device via sysfs after rc_unregister_device() Author: Sean Young Date: Sat Aug 8 13:38:02 2020 +0200 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 drivers/media/rc/rc-main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index e1cda80a4b25..dee8a9f3d80a 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1292,6 +1292,10 @@ static ssize_t store_protocols(struct device *device, } mutex_lock(&dev->lock); + if (!dev->registered) { + mutex_unlock(&dev->lock); + return -ENODEV; + } old_protocols = *current_protocols; new_protocols = old_protocols; @@ -1430,6 +1434,10 @@ static ssize_t store_filter(struct device *device, return -EINVAL; mutex_lock(&dev->lock); + if (!dev->registered) { + mutex_unlock(&dev->lock); + return -ENODEV; + } new_filter = *filter; if (fattr->mask) @@ -1544,6 +1552,10 @@ static ssize_t store_wakeup_protocols(struct device *device, int i; mutex_lock(&dev->lock); + if (!dev->registered) { + mutex_unlock(&dev->lock); + return -ENODEV; + } allowed = dev->allowed_wakeup_protocols;