From patchwork Fri Jun 19 06:54:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 31298 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5J6swSB027069 for ; Fri, 19 Jun 2009 06:54:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753859AbZFSGyx (ORCPT ); Fri, 19 Jun 2009 02:54:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755158AbZFSGyw (ORCPT ); Fri, 19 Jun 2009 02:54:52 -0400 Received: from mail.gmx.net ([213.165.64.20]:43545 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1756156AbZFSGyv (ORCPT ); Fri, 19 Jun 2009 02:54:51 -0400 Received: (qmail invoked by alias); 19 Jun 2009 06:54:51 -0000 Received: from p57BD1E73.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.30.115] by mail.gmx.net (mp058) with SMTP; 19 Jun 2009 08:54:51 +0200 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX1+DaeAlltODmWNzJFTQQXqTBkhMDeowjFIoE/59l8 YnK0YHP/FWus4F Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1MHY00-0001H9-P0; Fri, 19 Jun 2009 08:54:56 +0200 Date: Fri, 19 Jun 2009 08:54:56 +0200 (CEST) From: Guennadi Liakhovetski To: Kuninori Morimoto cc: Linux Media Mailing List Subject: [PATCH v2] soc-camera: fix missing clean up on error path In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.45 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org soc-camera: fix missing clean up on error path If soc_camera_init_user_formats() fails in soc_camera_probe(), we have to call client's .remove() method to unregister the video device. Reported-by: Kuninori Morimoto Signed-off-by: Guennadi Liakhovetski --- (please use the new V4L Mailing List) On Fri, 19 Jun 2009, Kuninori Morimoto wrote: > > If soc_camera_init_user_formats() fails in soc_camera_probe(), we have to call > > client's .remove() method to unregister the video device. > > > > Reported-by: Kuninori Morimoto > > Signed-off-by: Guennadi Liakhovetski > > --- > > Hi Morimoto-san > (snip) > > Could you please verify that this patch fixed your problem? > > Thank you nice patch. > I tried this, but kernel stoped in boot. > > soc_camera_video_stop is called from icd->ops->remove > I think it have dead lock by icd->video_lock. > > my kernel is from Paul's git and it's Makefile said 2.6.30-rc6 Yes, you're right. Please, try this version, but this is a bigger change, also affecting the regular (not error) path, so, I will have to test it too. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 78010ab..9f5ae81 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -877,8 +877,11 @@ static int soc_camera_probe(struct device *dev) (unsigned short)~0; ret = soc_camera_init_user_formats(icd); - if (ret < 0) + if (ret < 0) { + if (icd->ops->remove) + icd->ops->remove(icd); goto eiufmt; + } icd->height = DEFAULT_HEIGHT; icd->width = DEFAULT_WIDTH; @@ -902,8 +905,10 @@ static int soc_camera_remove(struct device *dev) { struct soc_camera_device *icd = to_soc_camera_dev(dev); + mutex_lock(&icd->video_lock); if (icd->ops->remove) icd->ops->remove(icd); + mutex_unlock(&icd->video_lock); soc_camera_free_user_formats(icd); @@ -1145,6 +1150,7 @@ evidallocd: } EXPORT_SYMBOL(soc_camera_video_start); +/* Called from client .remove() methods with .video_lock held */ void soc_camera_video_stop(struct soc_camera_device *icd) { struct video_device *vdev = icd->vdev; @@ -1154,10 +1160,8 @@ void soc_camera_video_stop(struct soc_camera_device *icd) if (!icd->dev.parent || !vdev) return; - mutex_lock(&icd->video_lock); video_unregister_device(vdev); icd->vdev = NULL; - mutex_unlock(&icd->video_lock); } EXPORT_SYMBOL(soc_camera_video_stop);