Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2815753pxb; Mon, 1 Nov 2021 02:22:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy3IvCjO7RiJAbjw0sbuv9O0P7bPjiT3LIDTS2GcGDlUbnanouZWIdSeBw4Yam/KzkBcX0 X-Received: by 2002:a5d:81c7:: with SMTP id t7mr20945887iol.65.1635758538091; Mon, 01 Nov 2021 02:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635758538; cv=none; d=google.com; s=arc-20160816; b=BAaJiOjrKJsy0vRe5PlKc4tlYkasXW5uQTa8jR+H0i0NRP10CUa5TtPsO6Mu/69znT ykFOHsvBI1HXtJXVfDjvbxSFw4Aha9klk42IACEo/T1GxQKY0ZIR0REd8LUagZRfTpoH hikCV35Azp7yMnl5Vz3Aqqlr1glUK+6iuOTA8TucU7eaZYL5qWbYZ5ogTpTvMU5PEAnY ma4wIzhYNLnylEOOkoPAcWv7w+bMCGaQnFbi5r2o1IyVPiYBaen2FJmcnea//Gds4GI+ 02m8ej3QRNQnov2QMNg8VfErYwpoW3JoEMeeDlfl3ivfGXeC7G/KcxqQeQLnHzXsVqMq B0yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zW4DbgBSRIDVLGXf90x0NCCfnGge7PvGF2LeqOIrX7s=; b=KXoqhBdR7nYyjVdPs+kFc8LviKtThxyBK15SdE4f8Vj8Kt+30peP2iYXuWn/WFwiRx B46afBIbBaT8xpRER1sPRkEuqEn7nlt/8Y3cV4L8N7a/XZYgQj6QYZ3+zw8XLx6bNBmq bH6/U9hdAfE4NZ0//s8C3BkOt6RrtW0ZhJWpAG+ZHFhw5DmMTeIAzR/LO6Y8nji4zn41 ztoRG5XPFDpItXnanDWRdpLfIsiz8VY1zCIPRX+IPmznfI26kKIBzbQXHln+KlmnQ73H q4ZbvA6c68ipminG5nrL1PeePIRnV9nYF8VlnG0tXKcUhFC2P9aQvFEcv/4/oc8PzyK9 PicA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dv6/a8wu"; 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=pass (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 y10si21472379iov.63.2021.11.01.02.22.06; Mon, 01 Nov 2021 02:22:18 -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=@linuxfoundation.org header.s=korg header.b="dv6/a8wu"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232138AbhKAJWm (ORCPT + 99 others); Mon, 1 Nov 2021 05:22:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:58178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232136AbhKAJV4 (ORCPT ); Mon, 1 Nov 2021 05:21:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A044610D2; Mon, 1 Nov 2021 09:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758350; bh=0CmTjJxR13ZvrJ+IvrfdOXjISYTycTnh7MP30n7QvrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dv6/a8wuejsSH1BUl3kHCWrCU7WPQ4U9f9nS/32nDGM5OYsW3IUJ85SS03AoXRn59 1VqY6rhXMYLSl5HyOiCL29DU0/wymi6QIvhJQVhmNtPw/GtxGOld6GBWARtAR4Luwd Oq2BwHAl28Eo0YGW0g8B5bs4W/1Kf/EhKZOwOMjQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yanfei Xu , Pavel Skripkin , Jakub Kicinski Subject: [PATCH 4.4 09/17] Revert "net: mdiobus: Fix memory leak in __mdiobus_register" Date: Mon, 1 Nov 2021 10:17:12 +0100 Message-Id: <20211101082442.644515254@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082440.664392327@linuxfoundation.org> References: <20211101082440.664392327@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin commit 10eff1f5788b6ffac212c254e2f3666219576889 upstream. This reverts commit ab609f25d19858513919369ff3d9a63c02cd9e2e. This patch is correct in the sense that we _should_ call device_put() in case of device_register() failure, but the problem in this code is more vast. We need to set bus->state to UNMDIOBUS_REGISTERED before calling device_register() to correctly release the device in mdiobus_free(). This patch prevents us from doing it, since in case of device_register() failure put_device() will be called 2 times and it will cause UAF or something else. Also, Reported-by: tag in revered commit was wrong, since syzbot reported different leak in same function. Link: https://lore.kernel.org/netdev/20210928092657.GI2048@kadam/ Acked-by: Yanfei Xu Signed-off-by: Pavel Skripkin Link: https://lore.kernel.org/r/f12fb1faa4eccf0f355788225335eb4309ff2599.1633024062.git.paskripkin@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/mdio_bus.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -274,7 +274,6 @@ int __mdiobus_register(struct mii_bus *b err = device_register(&bus->dev); if (err) { pr_err("mii_bus %s failed to register\n", bus->id); - put_device(&bus->dev); return -EINVAL; }