From patchwork Thu Jul 10 06:25:02 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: 33377 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7D8C6208CF for ; Thu, 10 Jul 2014 06:26:20 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id il7sf27805617vcb.4 for ; Wed, 09 Jul 2014 23:26:20 -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=g9JSmGLg2Y5lKAdMPaiul7j8ToUuArkW4Y2bdsQ98ok=; b=RDPLPDmeHj3eUUCq9yyz2pvU05YmmcUIdmUiq/SiXRd80hVxgA6AGriiUJi1q4edeq 77RccIqMJmVb5YL9WyS/FY5KAmZDT35SsghjAPDTMlyCb6ScLfHD+T4V2f6qVpkeSngH 0WaSfGAFpMepPCI0JKumot54dKgrHqsxfkhBufGIYxuUnSAaQ/nDEYEv6Jrf7XOdSIWJ eEu4/Jle93WsX7+yBaG9MwqDMJ10CuXID2Chaw70btlmvMVaGaiuRU5hSAAlyWRpH9bH lI6aCSJDWjFs1EJ+lnJRnCGwddndeQCfPxtAHAzckTu1E9tktaH0UVoqCLV/JJlLl+QZ f+hQ== X-Gm-Message-State: ALoCoQkwHr4EPWBzZXiv4S/w2DDn/q2Grczsx3OfTOk/QF4Lh01hAkxB90/LzVxnJVCFlE5qgj9k X-Received: by 10.236.19.7 with SMTP id m7mr19004559yhm.35.1404973580310; Wed, 09 Jul 2014 23:26:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.40 with SMTP id m37ls2886101qgd.18.gmail; Wed, 09 Jul 2014 23:26:20 -0700 (PDT) X-Received: by 10.58.150.1 with SMTP id ue1mr43195575veb.11.1404973580234; Wed, 09 Jul 2014 23:26:20 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id yr5si22543435vdb.14.2014.07.09.23.26.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 23:26:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id im17so9459200vcb.25 for ; Wed, 09 Jul 2014 23:26:20 -0700 (PDT) X-Received: by 10.58.229.162 with SMTP id sr2mr43488952vec.15.1404973580156; Wed, 09 Jul 2014 23:26:20 -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 tc5csp108027vcb; Wed, 9 Jul 2014 23:26:19 -0700 (PDT) X-Received: by 10.66.66.108 with SMTP id e12mr45660181pat.35.1404973579051; Wed, 09 Jul 2014 23:26:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si8210515pdl.195.2014.07.09.23.26.18; Wed, 09 Jul 2014 23:26:18 -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 S1751721AbaGJG0I (ORCPT + 28 others); Thu, 10 Jul 2014 02:26:08 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:38436 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751492AbaGJGZ1 (ORCPT ); Thu, 10 Jul 2014 02:25:27 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s6A6PQHB027944; Thu, 10 Jul 2014 01:25:26 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s6A6PQHk025294; Thu, 10 Jul 2014 01:25:26 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Thu, 10 Jul 2014 01:25:26 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s6A6PIrY010573; Thu, 10 Jul 2014 01:25:25 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 4/5] phy: core: Fix error path in phy_create() Date: Thu, 10 Jul 2014 11:55:02 +0530 Message-ID: <1404973503-3310-5-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404973503-3310-1-git-send-email-kishon@ti.com> References: <1404973503-3310-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.220.180 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. Cc: 3.13+ # 3.13+ 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); }