From patchwork Mon Jul 7 06:48:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 33126 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D38B420C88 for ; Mon, 7 Jul 2014 06:49:59 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf25629483oac.3 for ; Sun, 06 Jul 2014 23:49:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=NuQlPxtJAU/Tj8Bp6NZ+q4TftwUaubYovEHUjU7JKRc=; b=GQacMcshI2VTZTfDeCOUtA69h4rba12rAr74KeGW57q9cdDQd1jT6LGYXcpg1qK6iM deGYlrOUw/zjEVNK5XQucZAxFQSJzWqtW0Wtfe5KdnFTAX7atdYWEu9YJdAcFljb4XZL jXS10cAmhqs44/rrn2A8CXCfTgDjJV9C/LAfSLGUNNJyXguV7p8EpdnYO/gLSgv6pp6b TILOie+ioZM6LpefFWmOTXdWY5zGY+fMVURDI/RdRUoVIQTiDymIoKF8T+bVY22rUSa8 aUSPLgX0Ma+9ndVIbJR3fuuCodFa76aIuYSg6BDHUyznxHWFs3u+053tVTaIVe3TWY8w CFiQ== X-Gm-Message-State: ALoCoQn08O0Re+U04Y2v6P5+6LG8N1PzkHMDIh2L43g0T0aTgOKAKdU9GteKvlpRTgvcep0g4Akz X-Received: by 10.182.246.7 with SMTP id xs7mr12231531obc.15.1404715799492; Sun, 06 Jul 2014 23:49:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.72 with SMTP id k66ls1589673qgd.96.gmail; Sun, 06 Jul 2014 23:49:59 -0700 (PDT) X-Received: by 10.52.244.81 with SMTP id xe17mr21735797vdc.24.1404715799334; Sun, 06 Jul 2014 23:49:59 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id ca9si7212838vdc.71.2014.07.06.23.49.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 06 Jul 2014 23:49:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so3601288veb.14 for ; Sun, 06 Jul 2014 23:49:59 -0700 (PDT) X-Received: by 10.52.84.162 with SMTP id a2mr21854841vdz.23.1404715799249; Sun, 06 Jul 2014 23:49:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp643788vcb; Sun, 6 Jul 2014 23:49:58 -0700 (PDT) X-Received: by 10.68.134.98 with SMTP id pj2mr27051767pbb.98.1404715798442; Sun, 06 Jul 2014 23:49:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bt3si40395409pbb.82.2014.07.06.23.49.57; Sun, 06 Jul 2014 23:49:57 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbaGGGts (ORCPT + 27 others); Mon, 7 Jul 2014 02:49:48 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:49133 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751747AbaGGGsu (ORCPT ); Mon, 7 Jul 2014 02:48:50 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s676mn4s009432; Mon, 7 Jul 2014 01:48:49 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s676mntS007970; Mon, 7 Jul 2014 01:48:49 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Mon, 7 Jul 2014 01:48:49 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s676meMB028360; Mon, 7 Jul 2014 01:48:48 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 5/8] phy: core: Fix error path in phy_create() Date: Mon, 7 Jul 2014 12:18:22 +0530 Message-ID: <1404715705-5041-6-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404715705-5041-1-git-send-email-kishon@ti.com> References: <1404715705-5041-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kishon@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Roger Quadros Prevent resources from being freed twice in case device_add() call fails within phy_create(). Also use ida_simple_remove() instead of ida_remove() as we had used ida_simple_get() to allocate the ida. Signed-off-by: Roger Quadros Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/phy-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index c64a2f3..49c4465 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -614,8 +614,9 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, return phy; put_dev: - put_device(&phy->dev); - ida_remove(&phy_ida, phy->id); + put_device(&phy->dev); /* calls phy_release() which frees resources */ + return ERR_PTR(ret); + free_phy: kfree(phy); return ERR_PTR(ret); @@ -799,7 +800,7 @@ static void phy_release(struct device *dev) phy = to_phy(dev); dev_vdbg(dev, "releasing '%s'\n", dev_name(dev)); - ida_remove(&phy_ida, phy->id); + ida_simple_remove(&phy_ida, phy->id); kfree(phy); }