From patchwork Tue Jul 15 17:01:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sam-the-6 X-Patchwork-Id: 33677 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0BE0C201F1 for ; Tue, 15 Jul 2014 17:08:26 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id h18sf12738213igc.1 for ; Tue, 15 Jul 2014 10:08:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=NthfRmYCpq8sbqcVzbZhAiJb83n+PJgk7Hydw3wM5Q0=; b=CQ79b5BrNlcK33EHNq6Z0hixeIFLN9SrHhwgZJNJMb9MUH7oi1MIrBP9wgxS+jOr7R Sl7n9YWZH7DAS0fIRtiL3nv1nza51pPm9AtMbmzcC7P28dG+v1lxFaw5wF9hA3Zs4ISf nKaw0h5/B2nAT9tIxxCf7zQ6tBLZ2lcA9yoSlOdMXg2hnPgS+M65fs5NMxQFoOEcXkF9 cIiEPiGZqRFRP64GLz540gNaWKaRODf83hiuGKcnjXuC1gyMaLB0oSUw7y9EOjCu2/zl HwoYYdx3jW0kqH8zx+2yID66GEb1V9S4DuZDEBWFalsM8jubs8LTLGmOV3rEwe1aAos3 wQvw== X-Gm-Message-State: ALoCoQkCHEovmmto6bHxo+ryhc8CBtNGN9FPTjqBKz8C20cgrjyaT8GjMLsOva1/8X6R2t7xcdaB X-Received: by 10.182.92.169 with SMTP id cn9mr11633966obb.45.1405444105553; Tue, 15 Jul 2014 10:08:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.90.104 with SMTP id w95ls163744qgd.4.gmail; Tue, 15 Jul 2014 10:08:25 -0700 (PDT) X-Received: by 10.58.207.84 with SMTP id lu20mr23224710vec.9.1405444105466; Tue, 15 Jul 2014 10:08:25 -0700 (PDT) Received: from mail-vc0-x22b.google.com (mail-vc0-x22b.google.com [2607:f8b0:400c:c03::22b]) by mx.google.com with ESMTPS id j8si7061408vdi.16.2014.07.15.10.08.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 10:08:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22b as permitted sender) client-ip=2607:f8b0:400c:c03::22b; Received: by mail-vc0-f171.google.com with SMTP id id10so10792399vcb.2 for ; Tue, 15 Jul 2014 10:08:25 -0700 (PDT) X-Received: by 10.53.5.230 with SMTP id cp6mr18541760vdd.25.1405444105382; Tue, 15 Jul 2014 10:08:25 -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 tc5csp230926vcb; Tue, 15 Jul 2014 10:08:24 -0700 (PDT) X-Received: by 10.66.254.198 with SMTP id ak6mr1841417pad.156.1405444103244; Tue, 15 Jul 2014 10:08:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lc8si12202609pab.180.2014.07.15.10.08.22; Tue, 15 Jul 2014 10:08: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 S932507AbaGORIO (ORCPT + 28 others); Tue, 15 Jul 2014 13:08:14 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:42177 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755940AbaGORCU (ORCPT ); Tue, 15 Jul 2014 13:02:20 -0400 Received: by mail-wg0-f41.google.com with SMTP id z12so5975430wgg.24 for ; Tue, 15 Jul 2014 10:02:19 -0700 (PDT) X-Received: by 10.194.243.200 with SMTP id xa8mr14010000wjc.97.1405443739704; Tue, 15 Jul 2014 10:02:19 -0700 (PDT) Received: from Debian ([94.54.73.8]) by mx.google.com with ESMTPSA id n8sm18503387wia.19.2014.07.15.10.02.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 15 Jul 2014 10:02:19 -0700 (PDT) Received: from sam by Debian with local (Exim 4.80) (envelope-from ) id 1X767J-000450-45; Tue, 15 Jul 2014 20:02:13 +0300 From: Sam Asadi To: gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Roger Quadros , Kishon Vijay Abraham I , sam-the-6 Subject: [PATCH 74/94] phy: core: Fix error path in phy_create() Date: Tue, 15 Jul 2014 20:01:29 +0300 Message-Id: <1405443709-15288-74-git-send-email-asadi.samuel@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1405443709-15288-1-git-send-email-asadi.samuel@gmail.com> References: <1405443709-15288-1-git-send-email-asadi.samuel@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: asadi.samuel@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22b as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: sam-the-6 --- 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); }