From patchwork Thu Aug 12 07:46:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 119206 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7C7krLB024953 for ; Thu, 12 Aug 2010 07:46:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758857Ab0HLHqk (ORCPT ); Thu, 12 Aug 2010 03:46:40 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:54960 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758819Ab0HLHqi (ORCPT ); Thu, 12 Aug 2010 03:46:38 -0400 Received: by wwj40 with SMTP id 40so1197578wwj.1 for ; Thu, 12 Aug 2010 00:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=VLqvfO0i9EqQqpymQcB+Nn53+BN8BcLydkBSMnuaWJM=; b=mDrgljVayzysiHR/WU9AReDsEz4gaP6YDYNyLyGqWRUoSmngRZjcJ2B+O3iQKkkjVU OyY8T13JrWcSo2U1MSp4EzCXIelUH/1BtbpG5DyjeyEm2Ia3EjvBzK0L2sQHpyNmBTSg VCy25mtgZCyqXM4/gfoUjYcfIJvj1feIM4yVk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=Ccd2izhj7LXoQx80jxI3iWIcaRoomUHQa0kFpqQp7BFdBGa/1mkwHdKAWq9sZZhORp qoO/Quzsune72sM3q0f5vR5vsmu4TKJtFMmFmztJhNETJu/tFvclep4KnoTLFDKiJ8dy MCKzTGyCC6JdalrDDDaXrZT3zo2zrPYyfCoVs= Received: by 10.216.10.11 with SMTP id 11mr6381483weu.64.1281599196887; Thu, 12 Aug 2010 00:46:36 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id v44sm619743weq.4.2010.08.12.00.46.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 12 Aug 2010 00:46:36 -0700 (PDT) Date: Thu, 12 Aug 2010 09:46:11 +0200 From: Dan Carpenter To: Maxim Levitsky Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] IR: ene_ir: problems in unwinding on probe Message-ID: <20100812074611.GI645@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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.3 (demeter.kernel.org [140.211.167.41]); Thu, 12 Aug 2010 07:46:54 +0000 (UTC) diff --git a/drivers/media/IR/ene_ir.c b/drivers/media/IR/ene_ir.c index 5447750..8e5e964 100644 --- a/drivers/media/IR/ene_ir.c +++ b/drivers/media/IR/ene_ir.c @@ -781,21 +781,24 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) /* allocate memory */ input_dev = input_allocate_device(); + if (!input_dev) + goto err_out; ir_props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL); + if (!ir_props) + goto err_input_dev; dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); - - if (!input_dev || !ir_props || !dev) - goto error; + if (!dev) + goto err_ir_props; /* validate resources */ error = -ENODEV; if (!pnp_port_valid(pnp_dev, 0) || pnp_port_len(pnp_dev, 0) < ENE_MAX_IO) - goto error; + goto err_dev; if (!pnp_irq_valid(pnp_dev, 0)) - goto error; + goto err_dev; dev->hw_io = pnp_port_start(pnp_dev, 0); dev->irq = pnp_irq(pnp_dev, 0); @@ -804,11 +807,11 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) /* claim the resources */ error = -EBUSY; if (!request_region(dev->hw_io, ENE_MAX_IO, ENE_DRIVER_NAME)) - goto error; + goto err_dev; if (request_irq(dev->irq, ene_isr, IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) - goto error; + goto err_region; pnp_set_drvdata(pnp_dev, dev); dev->pnp_dev = pnp_dev; @@ -816,7 +819,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) /* detect hardware version and features */ error = ene_hw_detect(dev); if (error) - goto error; + goto err_irq; ene_setup_settings(dev); @@ -889,20 +892,22 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) error = -ENODEV; if (ir_input_register(input_dev, RC_MAP_RC6_MCE, ir_props, ENE_DRIVER_NAME)) - goto error; - + goto err_irq; ene_printk(KERN_NOTICE, "driver has been succesfully loaded\n"); return 0; -error: - if (dev->irq) - free_irq(dev->irq, dev); - if (dev->hw_io) - release_region(dev->hw_io, ENE_MAX_IO); - input_free_device(input_dev); - kfree(ir_props); +err_irq: + free_irq(dev->irq, dev); +err_region: + release_region(dev->hw_io, ENE_MAX_IO); +err_dev: kfree(dev); +err_ir_props: + kfree(ir_props); +err_input_dev: + input_free_device(input_dev); +err_out: return error; }