From patchwork Wed Jul 2 12:03:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 32973 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f72.google.com (mail-qg0-f72.google.com [209.85.192.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DEEA320672 for ; Wed, 2 Jul 2014 12:05:14 +0000 (UTC) Received: by mail-qg0-f72.google.com with SMTP id q107sf11032413qgd.3 for ; Wed, 02 Jul 2014 05:05:14 -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=AQDH8faHR3HQfPUZncGE9qwRHhiA4v3wWz6eMzx2zGk=; b=IlyCqhp3EWkdLPs3MGyWOUEAw3UlGnLzMypZCfzykQmMLvu421O/AJF8z0rEAF/X2N SIhYTMtnGoi2Nh0fp3xchLYNmndQM27nUJdstctMInDXbHHc4clN2rl3JqQXmtGLsnhq 6d9Ni5RpgwzT51/uHGw8G0ioSfdCCbYEX3gBK7rlSAGoVTTbkK5+wHLMkr9xuaGzTiHo UKEqjkpmDPxBN31LEv9hp15qpnIJ+mjSyIk7oQ4ffFnJ4n4nB4oGikLymTPfg+ttFK6b aDDuBReHgdgmJHIwlgVgv+c54A+nD4wg5TDx6zbFiAHTvEsiao/6pvZ+qnYu0AfMd0Gw HLOQ== X-Gm-Message-State: ALoCoQl1SL/zdIDoUqaprrgb/6wk4kIc2ZCfIqxYeH8jov1oYF0nS6GFAfdS9U5QQxhBSzsZlrpC X-Received: by 10.236.111.1 with SMTP id v1mr6067052yhg.44.1404302714476; Wed, 02 Jul 2014 05:05:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.102 with SMTP id 93ls15068qgo.10.gmail; Wed, 02 Jul 2014 05:05:14 -0700 (PDT) X-Received: by 10.52.7.163 with SMTP id k3mr761vda.58.1404302714282; Wed, 02 Jul 2014 05:05:14 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id zu9si12765650vdc.75.2014.07.02.05.05.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Jul 2014 05:05:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id i13so10856763veh.8 for ; Wed, 02 Jul 2014 05:05:14 -0700 (PDT) X-Received: by 10.220.163.3 with SMTP id y3mr49323115vcx.7.1404302664103; Wed, 02 Jul 2014 05:04:24 -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 tc5csp287891vcb; Wed, 2 Jul 2014 05:04:23 -0700 (PDT) X-Received: by 10.66.234.202 with SMTP id ug10mr3466955pac.109.1404302663360; Wed, 02 Jul 2014 05:04:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id da4si30049293pbb.222.2014.07.02.05.04.22; Wed, 02 Jul 2014 05:04:22 -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 S1752540AbaGBMEP (ORCPT + 27 others); Wed, 2 Jul 2014 08:04:15 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:33854 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751524AbaGBMEM (ORCPT ); Wed, 2 Jul 2014 08:04:12 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s62C4BDY015723; Wed, 2 Jul 2014 07:04:11 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s62C4BZX007730; Wed, 2 Jul 2014 07:04:11 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Wed, 2 Jul 2014 07:04:11 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s62C41PH005005; Wed, 2 Jul 2014 07:04:08 -0500 From: Roger Quadros To: , , CC: , , , , , , Roger Quadros Subject: [PATCH 2/6] phy: core: Fix error path in phy_create() Date: Wed, 2 Jul 2014 15:03:54 +0300 Message-ID: <1404302638-3003-3-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1404302638-3003-1-git-send-email-rogerq@ti.com> References: <1404302638-3003-1-git-send-email-rogerq@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: rogerq@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.177 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: , 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 --- 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); }