From patchwork Wed Jan 6 20:27:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 7970641 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 36362BEEED for ; Wed, 6 Jan 2016 20:28:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 482DC20120 for ; Wed, 6 Jan 2016 20:28:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FC6420172 for ; Wed, 6 Jan 2016 20:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752305AbcAFU2E (ORCPT ); Wed, 6 Jan 2016 15:28:04 -0500 Received: from resqmta-po-06v.sys.comcast.net ([96.114.154.165]:60709 "EHLO resqmta-po-06v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752289AbcAFU1k (ORCPT ); Wed, 6 Jan 2016 15:27:40 -0500 Received: from resomta-po-05v.sys.comcast.net ([96.114.154.229]) by resqmta-po-06v.sys.comcast.net with comcast id 2kTW1s00F4xDoy801kTdeM; Wed, 06 Jan 2016 20:27:37 +0000 Received: from mail.gonehiking.org ([73.181.52.62]) by resomta-po-05v.sys.comcast.net with comcast id 2kTU1s00A1LXgTt01kTcnC; Wed, 06 Jan 2016 20:27:37 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 7B46F9F435; Wed, 6 Jan 2016 13:27:35 -0700 (MST) From: Shuah Khan To: mchehab@osg.samsung.com, tiwai@suse.com, clemens@ladisch.de, hans.verkuil@cisco.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, javier@osg.samsung.com Cc: Shuah Khan , pawel@osciak.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, perex@perex.cz, arnd@arndb.de, dan.carpenter@oracle.com, tvboxspy@gmail.com, crope@iki.fi, ruchandani.tina@gmail.com, corbet@lwn.net, chehabrafael@gmail.com, k.kozlowski@samsung.com, stefanr@s5r6.in-berlin.de, inki.dae@samsung.com, jh1009.sung@samsung.com, elfring@users.sourceforge.net, prabhakar.csengg@gmail.com, sw0312.kim@samsung.com, p.zabel@pengutronix.de, ricardo.ribalda@gmail.com, labbott@fedoraproject.org, pierre-louis.bossart@linux.intel.com, ricard.wanderlof@axis.com, julian@jusst.de, takamichiho@gmail.com, dominic.sacre@gmx.de, misterpib@gmail.com, daniel@zonque.org, gtmkramer@xs4all.nl, normalperson@yhbt.net, joe@oampo.co.uk, linuxbugs@vittgam.net, johan@oljud.se, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-api@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 24/31] media: au0828 fix null pointer reference in au0828_create_media_graph() Date: Wed, 6 Jan 2016 13:27:13 -0700 Message-Id: <33b9da8f01b1d94844ac677efd31a66c40c39ecb.1452105878.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1452112057; bh=vZrMkQKn3C73Uqj3e8UC+bOTOZKS8bLXooaPG6u6wA4=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=lSg+A/tMI9Hr5R487jcvzKpU0Dtyalr5rdxTZ1o0BU+6LylrL0wmcj5NIJ1YRIUKO Yn+P02JIScJRQq9/3+n18WmZU/Z5xFl2Ui0+WwDAf8wETcYXOiZA8X/2mwn9q40IMv z8VH9lZalAMQTddf4Yri6eVy/5TA9cw/CjKpNEyFD9xwlDPQz3zRv4COKYK0xKCn9L 7BkFrBNzTrU+nb3IOm+feum3314wDCO1OhoLNHVaXHMaqo6ywDtZAWVacGTYrj7b8f xv2dz7Yr4mCkJOeMCGqAKP732GkG1XmZoUNm3f7UAp80u3B7UGZPhSh2pu4z9s2l6i ByUr18sMsAp6g== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new wrapper function to au0828_create_media_graph() to be called as an entity_notify function to fix null pointer dereference. A rebasing mistake resulted in registering au0828_create_media_graph() without the correct parameters which lead to the following null pointer dereference: [ 69.006164] Call Trace: [ 69.006169] [] dump_stack+0x44/0x64 [ 69.006175] [] print_trailer+0xf9/0x150 [ 69.006180] [] object_err+0x34/0x40 [ 69.006185] [] ? ___slab_alloc+0x4c4/0x4e0 [ 69.006190] [] kasan_report_error+0x212/0x520 [ 69.006196] [] ? ___slab_alloc+0x4c4/0x4e0 [ 69.006201] [] __asan_report_load1_noabort+0x43/0x50 [ 69.006208] [] ? au0828_create_media_graph+0x641/0x730 [au0828] [ 69.006215] [] au0828_create_media_graph+0x641/0x730 [au0828] [ 69.006221] [] media_device_register_entity+0x33d/0x4f0 [ 69.006234] [] media_stream_init+0x2ac/0x610 [snd_usb_audio] [ 69.006247] [] snd_usb_pcm_open+0xcd0/0x1280 [snd_usb_audio] Signed-off-by: Shuah Khan --- drivers/media/usb/au0828/au0828-core.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index f8d2db3..9497ad1 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -370,6 +370,20 @@ static int au0828_create_media_graph(struct au0828_dev *dev) return 0; } +void au0828_create_media_graph_notify(struct media_entity *new, + void *notify_data) +{ +#ifdef CONFIG_MEDIA_CONTROLLER + struct au0828_dev *dev = (struct au0828_dev *) notify_data; + int ret; + + ret = au0828_create_media_graph(dev); + if (ret) + pr_err("%s() media graph create failed for new entity %s\n", + __func__, new->name); +#endif +} + static int au0828_enable_source(struct media_entity *entity, struct media_pipeline *pipe) { @@ -535,7 +549,7 @@ static int au0828_media_device_register(struct au0828_dev *dev, } /* register entity_notify callback */ dev->entity_notify.notify_data = (void *) dev; - dev->entity_notify.notify = (void *) au0828_create_media_graph; + dev->entity_notify.notify = au0828_create_media_graph_notify; ret = media_device_register_entity_notify(dev->media_dev, &dev->entity_notify); if (ret) {