From patchwork Tue Apr 12 01:00:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 8806481 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7016BC0553 for ; Tue, 12 Apr 2016 01:00:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 889232034C for ; Tue, 12 Apr 2016 01:00:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99F3D20340 for ; Tue, 12 Apr 2016 01:00:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755377AbcDLBAJ (ORCPT ); Mon, 11 Apr 2016 21:00:09 -0400 Received: from mailout.easymail.ca ([64.68.201.169]:47428 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754760AbcDLBAI (ORCPT ); Mon, 11 Apr 2016 21:00:08 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 85E58E91D; Mon, 11 Apr 2016 21:00:06 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at mailout.easymail.ca X-Spam-Score: -3.695 X-Spam-Level: X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (easymail-mailout.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1zgCkFTruMi4; Mon, 11 Apr 2016 21:00:06 -0400 (EDT) Received: from mail.gonehiking.org (c-73-181-52-62.hsd1.co.comcast.net [73.181.52.62]) by mailout.easymail.ca (Postfix) with ESMTPA id 7CE5AEA69; Mon, 11 Apr 2016 21:00:03 -0400 (EDT) Received: from shuah-XPS-13-9350.sisa.samsung.com (shuah-xps.internal [192.168.1.87]) by mail.gonehiking.org (Postfix) with ESMTP id 1CF4F9F291; Mon, 11 Apr 2016 19:00:03 -0600 (MDT) From: Shuah Khan To: mchehab@osg.samsung.com Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH] media: remove Managed Media Interfaces Date: Mon, 11 Apr 2016 19:00:02 -0600 Message-Id: <1460422802-10606-1-git-send-email-shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.5.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove Managed Media Interfaces: media_device_get_devres() media_device_find_devres() Using these interfaces leads to use-after-free race conditions on the shared media device during media device unregister by drivers using it. Signed-off-by: Shuah Khan --- drivers/media/media-device.c | 26 -------------------------- include/media/media-device.h | 32 -------------------------------- 2 files changed, 58 deletions(-) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 6e43c95..a2861ca 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -820,32 +820,6 @@ void media_device_unregister(struct media_device *mdev) } EXPORT_SYMBOL_GPL(media_device_unregister); -static void media_device_release_devres(struct device *dev, void *res) -{ -} - -struct media_device *media_device_get_devres(struct device *dev) -{ - struct media_device *mdev; - - mdev = devres_find(dev, media_device_release_devres, NULL, NULL); - if (mdev) - return mdev; - - mdev = devres_alloc(media_device_release_devres, - sizeof(struct media_device), GFP_KERNEL); - if (!mdev) - return NULL; - return devres_get(dev, mdev, NULL, NULL); -} -EXPORT_SYMBOL_GPL(media_device_get_devres); - -struct media_device *media_device_find_devres(struct device *dev) -{ - return devres_find(dev, media_device_release_devres, NULL, NULL); -} -EXPORT_SYMBOL_GPL(media_device_find_devres); - void media_device_pci_init(struct media_device *mdev, struct pci_dev *pci_dev, const char *name) diff --git a/include/media/media-device.h b/include/media/media-device.h index df74cfa..1642001 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -584,30 +584,6 @@ int __must_check media_device_register_entity_notify(struct media_device *mdev, void media_device_unregister_entity_notify(struct media_device *mdev, struct media_entity_notify *nptr); -/** - * media_device_get_devres() - get media device as device resource - * creates if one doesn't exist - * - * @dev: pointer to struct &device. - * - * Sometimes, the media controller &media_device needs to be shared by more - * than one driver. This function adds support for that, by dynamically - * allocating the &media_device and allowing it to be obtained from the - * struct &device associated with the common device where all sub-device - * components belong. So, for example, on an USB device with multiple - * interfaces, each interface may be handled by a separate per-interface - * drivers. While each interface have its own &device, they all share a - * common &device associated with the hole USB device. - */ -struct media_device *media_device_get_devres(struct device *dev); - -/** - * media_device_find_devres() - find media device as device resource - * - * @dev: pointer to struct &device. - */ -struct media_device *media_device_find_devres(struct device *dev); - /* Iterate over all entities. */ #define media_device_for_each_entity(entity, mdev) \ list_for_each_entry(entity, &(mdev)->entities, graph_obj.list) @@ -683,14 +659,6 @@ static inline void media_device_unregister_entity_notify( struct media_entity_notify *nptr) { } -static inline struct media_device *media_device_get_devres(struct device *dev) -{ - return NULL; -} -static inline struct media_device *media_device_find_devres(struct device *dev) -{ - return NULL; -} static inline void media_device_pci_init(struct media_device *mdev, struct pci_dev *pci_dev,