From patchwork Tue Sep 6 22:29:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1127052 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p86MTEQj013880 for ; Tue, 6 Sep 2011 22:29:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753270Ab1IFW3M (ORCPT ); Tue, 6 Sep 2011 18:29:12 -0400 Received: from perceval.ideasonboard.com ([95.142.166.194]:37057 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753229Ab1IFW3L (ORCPT ); Tue, 6 Sep 2011 18:29:11 -0400 Received: from localhost.localdomain (unknown [91.178.21.143]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 63FED359BB; Tue, 6 Sep 2011 22:29:10 +0000 (UTC) From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: JJosh Boyer , Dave Jones , Jonathan Nieder , Daniel Dickinson , 637740@bugs.debian.org Subject: [PATCH] uvcvideo: Fix crash when linking entities Date: Wed, 7 Sep 2011 00:29:08 +0200 Message-Id: <1315348148-7207-1-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.3.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 06 Sep 2011 22:29:16 +0000 (UTC) The uvc_mc_register_entity() function wrongfully selects the media_entity associated with a UVC entity when creating links. This results in access to uninitialized media_entity structures and can hit a BUG_ON statement in media_entity_create_link(). Fix it. Signed-off-by: Laurent Pinchart --- drivers/media/video/uvc/uvc_entity.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) This patch should fix a v3.0 regression that results in a kernel crash as reported in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637740 and https://bugzilla.redhat.com/show_bug.cgi?id=735437. Test results will be welcome. diff --git a/drivers/media/video/uvc/uvc_entity.c b/drivers/media/video/uvc/uvc_entity.c index 48fea37..29e2399 100644 --- a/drivers/media/video/uvc/uvc_entity.c +++ b/drivers/media/video/uvc/uvc_entity.c @@ -49,7 +49,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain, if (remote == NULL) return -EINVAL; - source = (UVC_ENTITY_TYPE(remote) != UVC_TT_STREAMING) + source = (UVC_ENTITY_TYPE(remote) == UVC_TT_STREAMING) ? (remote->vdev ? &remote->vdev->entity : NULL) : &remote->subdev.entity; if (source == NULL)