Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2127094pxb; Mon, 12 Apr 2021 15:21:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYo1ajuEE86FvNqLhbQdAdlcrky4brUjmVnovswrgFl7l5H2XB/z9kDd2ZQ1y1LkOnMnU9 X-Received: by 2002:a63:dc49:: with SMTP id f9mr28689855pgj.361.1618266097945; Mon, 12 Apr 2021 15:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618266097; cv=none; d=google.com; s=arc-20160816; b=jZhIHDIYPnHhUGtWd3A1gqoGNP6G1aT/tHB9lppVhilmEAxH3D5IO7oaY3KR81Sd4L Emdj18IKQkcCLsGrz9jaY2Oc90KxCXI/LWeKtYmrMSfdXIksiPJ1hDeOmOgnMK3WhyBk qF/9Fc6tjFA2wqkDQ8vPxouUpeBm+/SNbZ0mkC4wb0I/xyd1KQpKlOXBREz6ecfSYwWz wmmoRvjCdoqPP3NlbeqFNwMQmP1S++40oNpm9i7md4eZMloJ2/CJyTk5ETNfxk4hGWbK /jcMbOm8loBgXxNy+jeLg+qPn4qSSuqBRiw/N5EkIJwG0M2BxlIHqdAbChKkQdfWUjV7 eeBw== 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=SaK6cEqFd8iiDE6Rl4rlGHBUuLP7sFtTwBisxQSBaZk=; b=0OzAZu1yLIK2/0l121eyzqDnmpnpzV08301l3lble3ZJ8uTd78Erifq/WZe4smLCxS tB57PLvRi0VLVPdanyWjPtnGzRV795ji/MGnMfip/pg7yu9YghPynWOjLiHgmliChDPa l69qOD1/BopQkhjG+ifoShKa6Od36fIFTnNy3cBg/5Kf+U6iQLNXfcDCM09OzGCiVdjK DDvk39kt/QUtv1NSng05jlhh6vRp6RrsoIeLfO7pEvgLfL6oTtYbObuqNd6BHI5Aqhwk MNJxxCFznmQG6IppNnPhouywIA836sIUbLs6M11X7hUxnSYjiiRy9Ur6jKdZlKoZsEw6 BD5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BJU6UjIZ; 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 o9si2280723pld.384.2021.04.12.15.21.25; Mon, 12 Apr 2021 15:21:37 -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=BJU6UjIZ; 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 S242500AbhDLJ2p (ORCPT + 99 others); Mon, 12 Apr 2021 05:28:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:54804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239994AbhDLJE0 (ORCPT ); Mon, 12 Apr 2021 05:04:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 60F8861262; Mon, 12 Apr 2021 09:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618218119; bh=F8b3vb5PTEDH2Um/4peEt+2NFeHbIcQ86UXLBpPN+Ew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BJU6UjIZ4Xbb4iM114kjjhx0ke1a5lwQ6x/2kd+/vhchxlttL5vwv8TOMmhFMa7k/ xRscV1k5ZJxpATsxWUrBf9KumaVvXZUD1UByIO4MzqdqACUtD1h7EwztgbKkmM6n4c VwD22dnZeBzzpOrAk7IaWK7rv8iznUaFt0fjW050= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Jason Gunthorpe , Mika Westerberg Subject: [PATCH 5.11 078/210] thunderbolt: Fix a leak in tb_retimer_add() Date: Mon, 12 Apr 2021 10:39:43 +0200 Message-Id: <20210412084018.615202728@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@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: Dan Carpenter commit bec4d7c93afc07dd0454ae41c559513f858cfb83 upstream. After the device_register() succeeds, then the correct way to clean up is to call device_unregister(). The unregister calls both device_del() and device_put(). Since this code was only device_del() it results in a memory leak. Fixes: dacb12877d92 ("thunderbolt: Add support for on-board retimers") Cc: stable@vger.kernel.org Signed-off-by: Dan Carpenter Reviewed-by: Jason Gunthorpe Signed-off-by: Mika Westerberg Signed-off-by: Greg Kroah-Hartman --- drivers/thunderbolt/retimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/thunderbolt/retimer.c +++ b/drivers/thunderbolt/retimer.c @@ -347,7 +347,7 @@ static int tb_retimer_add(struct tb_port ret = tb_retimer_nvm_add(rt); if (ret) { dev_err(&rt->dev, "failed to add NVM devices: %d\n", ret); - device_del(&rt->dev); + device_unregister(&rt->dev); return ret; }