From patchwork Tue Nov 20 05:22:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 12964 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 913CA23FC2 for ; Tue, 20 Nov 2012 05:29:11 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4185FA18F7F for ; Tue, 20 Nov 2012 05:29:11 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so1484290iag.11 for ; Mon, 19 Nov 2012 21:29:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=q9RETQRbhcuyOQHq9vUTS64EEIdoIRd6ahv4mrQXImo=; b=Wl/7NDRPQKv3kIOE5SuoLShsUm3tA1proG7uLvfu81nmABUx4IpUioXjFdf9kUynKC kxLguH36wzC947XJq2BkypsQIV4NUNLwYWanNX/kcHUOd+04AqLMYljrXejou5lk6uhQ ZkHwvxdZ/39Ju5TMVhK3313gQ5GcNayH35Lqh0rBkbwwphhigOp99A8iNLtaNv224OXp w9+WQ/LyPZ1G3x1FLZrFqtazHXEydzgY4mOBI72uKXHZerYINj5e/UtQGkCC5K7b7ILI Hw8/wdB5CNedZWyIFNoFNSGhbOT68vYiTWqQysQ2vJWKkb4JfzaU2KPX1QDsVZS3Vpeq oPyg== Received: by 10.50.213.69 with SMTP id nq5mr8776901igc.70.1353389350999; Mon, 19 Nov 2012 21:29:10 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp271285igt; Mon, 19 Nov 2012 21:29:10 -0800 (PST) Received: by 10.68.238.72 with SMTP id vi8mr39462721pbc.55.1353389350518; Mon, 19 Nov 2012 21:29:10 -0800 (PST) Received: from mail-pb0-f41.google.com (mail-pb0-f41.google.com [209.85.160.41]) by mx.google.com with ESMTPS id s9si16397031pav.88.2012.11.19.21.29.10 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Nov 2012 21:29:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.41 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.41; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.41 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pb0-f41.google.com with SMTP id xa7so3603875pbc.28 for ; Mon, 19 Nov 2012 21:29:10 -0800 (PST) Received: by 10.66.88.102 with SMTP id bf6mr4933945pab.10.1353389350287; Mon, 19 Nov 2012 21:29:10 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id d2sm7429712paw.19.2012.11.19.21.29.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Nov 2012 21:29:09 -0800 (PST) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: myungjoo.ham@samsung.com, cw00.choi@samsung.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 5/7] extcon: max77693: Fix incorrect error check and return value Date: Tue, 20 Nov 2012 10:52:41 +0530 Message-Id: <1353388963-23761-6-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1353388963-23761-1-git-send-email-sachin.kamat@linaro.org> References: <1353388963-23761-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQnsgSEIQkkiPkSsTkFRg1pBZRIj5yfw44a18NzofEec5mKw31uw2ZPBlSp2Dy8oxZ+VU8SD irq_create_mapping() returns 0 if it fails to provide a valid irq number. 'ret' needs to be updated with a negative error code before returning from probe to signal probe failure. While at it, also corrected the 'virq' type to unsigned from signed. Signed-off-by: Sachin Kamat --- drivers/extcon/extcon-max77693.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index a17d0d9..2a0f397 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -686,11 +686,13 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) /* Support irq domain for MAX77693 MUIC device */ for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { struct max77693_muic_irq *muic_irq = &muic_irqs[i]; - int virq = 0; + unsigned int virq = 0; virq = irq_create_mapping(max77693->irq_domain, muic_irq->irq); - if (!virq) + if (!virq) { + ret = -EINVAL; goto err_irq; + } muic_irq->virq = virq; ret = request_threaded_irq(virq, NULL, @@ -702,8 +704,6 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) " error :%d)\n", muic_irq->irq, ret); - for (i = i - 1; i >= 0; i--) - free_irq(muic_irq->virq, info); goto err_irq; } } @@ -768,6 +768,8 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) err_extcon: kfree(info->edev); err_irq: + while (--i >= 0) + free_irq(muic_irqs[i].virq, info); err_regmap: kfree(info); err_kfree: