From patchwork Wed Mar 30 07:48:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 673462 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2U7m68o003669 for ; Wed, 30 Mar 2011 07:48:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754560Ab1C3HsE (ORCPT ); Wed, 30 Mar 2011 03:48:04 -0400 Received: from perceval.ideasonboard.com ([95.142.166.194]:51350 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752789Ab1C3HsD (ORCPT ); Wed, 30 Mar 2011 03:48:03 -0400 Received: from localhost.localdomain (77.162-65-87.adsl-dyn.isp.belgacom.be [87.65.162.77]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C375B35B86 for ; Wed, 30 Mar 2011 07:48:01 +0000 (UTC) From: Laurent Pinchart To: linux-media@vger.kernel.org Subject: [PATCH] v4l: Release module if subdev registration fails Date: Wed, 30 Mar 2011 09:48:21 +0200 Message-Id: <1301471301-8946-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]); Wed, 30 Mar 2011 07:48:06 +0000 (UTC) diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c index 5aeaf87..4aae501 100644 --- a/drivers/media/video/v4l2-device.c +++ b/drivers/media/video/v4l2-device.c @@ -155,8 +155,10 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, sd->v4l2_dev = v4l2_dev; if (sd->internal_ops && sd->internal_ops->registered) { err = sd->internal_ops->registered(sd); - if (err) + if (err) { + module_put(sd->owner); return err; + } } /* This just returns 0 if either of the two args is NULL */ @@ -164,6 +166,7 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, if (err) { if (sd->internal_ops && sd->internal_ops->unregistered) sd->internal_ops->unregistered(sd); + module_put(sd->owner); return err; }