Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2658636pxa; Mon, 17 Aug 2020 15:45:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkB98SxZ7O0L5Fadpgu713Xn+RmDiqBTJ+F43VgN5P8NFlJ9TrKD8qLUKVNKyi5fWSc0oU X-Received: by 2002:a17:906:528d:: with SMTP id c13mr17723645ejm.61.1597704342415; Mon, 17 Aug 2020 15:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704342; cv=none; d=google.com; s=arc-20160816; b=ClEDrAUeMmtIQb7CjTgWVvyH2f2qmYME2H/Gk7qDY9fMVrGaZ5sSIWc4H0JeFeXGt4 8NAgDKLWcm+RtxU+nhwrhPq17Wi7S7eMGgjDuW+TNzdVGvkkejV2/obL9098Gytrn4jN jAiSFiwPOZGoz8IkoG9Xr2641BevUBDpvGzpjLWB5ZdVcjrcRd4ys1Bs0SDmABUH2GtN s19K2ltrXur6dIgXtqVNzRFR2PaIzms0V0lnf+KBNWU8RIAj0SPFyaL2LdGJWHQQIlGU 5WulMlhIt36LybRfPxEf/KmHZK68nVZSpdZx7nY60juZTUjw7zkK+2SHUs3qYuuRH0kK qwbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U+SBxLvJ7vqtq5ZZ7tH1xwZFOurH+g4cq6K51V/qk1A=; b=KVrY/L3dsknyUDlq2ER2TieUNR+dHa5TMVTeW+CloqYU3a3oVJoU0JDbfh83JM2z01 h2m/7M0TCzoAY2JuTcG7XLJCA+vecDm6OY7u6wNzmTSQOU3qvWV5U6208+EDEzzBAeXv 6c/GXk3dEYjBoNyRrTm/gMC8vNWJm+dg2ikOpWTDEjhDCxs/qm6/OE6XMs9vj71lfyld uq6OBMk+ZazhBdmjTVdknYneiReCk943AD7fYPufovWS0jYQ75l/kwyRPIiPBkjqk9h9 ceCV7sYq8eauS/fCFuQGpAY0lzhSgD2KDLw3F4h2PHiX021Phsn7pOjM//9CLY+LkKti Z2xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cklv+5HA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si11345145edx.156.2020.08.17.15.45.19; Mon, 17 Aug 2020 15:45:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cklv+5HA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730582AbgHQTSK (ORCPT + 99 others); Mon, 17 Aug 2020 15:18:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:45832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730270AbgHQPiD (ORCPT ); Mon, 17 Aug 2020 11:38:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 12CD023134; Mon, 17 Aug 2020 15:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678680; bh=1MCbLa/2FROptC0TWFoBxOWO79n1UkwvKYg/ofYlKiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cklv+5HAKEkal5vZdE5K1TftXutHsBhu59vfNV5qvZRF+tegWFOIYNk4KTF3JNd1I Ge4+1y7AV4u4S7xRBof68/C4R1Ow4sXt7al9jBahE3UhVf0+yiBldEzIoHMCe/Vhi9 YgkZlIQMGV4KkVmDqXiqduGbZhGkEnen9YD+ggc0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiner Kallweit , Johan Hovold , "David S. Miller" Subject: [PATCH 5.8 387/464] net: phy: fix memory leak in device-create error path Date: Mon, 17 Aug 2020 17:15:40 +0200 Message-Id: <20200817143852.318634090@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold [ Upstream commit d02cbc46136105cf86f84ac355e16f04696f538d ] A recent commit introduced a late error path in phy_device_create() which fails to release the device name allocated by dev_set_name(). Fixes: 13d0ab6750b2 ("net: phy: check return code when requesting PHY driver module") Cc: Heiner Kallweit Signed-off-by: Johan Hovold Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/phy_device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -616,7 +616,9 @@ struct phy_device *phy_device_create(str if (c45_ids) dev->c45_ids = *c45_ids; dev->irq = bus->irq[addr]; + dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr); + device_initialize(&mdiodev->dev); dev->state = PHY_DOWN; @@ -650,10 +652,8 @@ struct phy_device *phy_device_create(str ret = phy_request_driver_module(dev, phy_id); } - if (!ret) { - device_initialize(&mdiodev->dev); - } else { - kfree(dev); + if (ret) { + put_device(&mdiodev->dev); dev = ERR_PTR(ret); }