Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp775648ybt; Fri, 19 Jun 2020 13:27:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFAsJLtvXjDC2hn2CuMC9cVlcaUKNb40WWYu+4DOidxm8z5aqOEPDVGpL5IvgnfK1H0MIR X-Received: by 2002:a05:6402:1a48:: with SMTP id bf8mr5229588edb.133.1592598444916; Fri, 19 Jun 2020 13:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592598444; cv=none; d=google.com; s=arc-20160816; b=tr+2ExbLy/yZsM1JOL2XuA1u9+sU1Gc37tzKrQU01YoNzGfoLvDNNgjtmhzsr39J69 Ns7qxqro40Tk5pA55KsAqWy4karm0zsQK26GHATu6I7fDIFHSRTAaBZSL9izWrGo+C6J w5OzE2RBSj91CXU2dUh7WQZpsGGPBp/JejKNUxRfoIeTfN8poXMPGB9ZJCpNpRZmyvTN k7B1d8z8EKd8TyPGZQ1Yz7IwuBteWpyMAF622g6w7fLzZFCvXr7RQVIrYCztWae8L+nh CWZgDWiFi0g3zbUOya4PCAGrZmvtEJNL0Re5WEvlk8OhVexcOthNZnHptcf6XbiFXhx1 fSyg== 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=7a7zhZ8h2NV/PfZHpJ9MvPuDqnoEc0SvkaF7rVsHjD8=; b=Zi+4zPtfuXXKY01WS4k5ZnaDv3hJaOjLFvpCDOVDrwG6x+pi77+YrAcfc33EIfqGLp gx+AQgSJ8GeQsgwTlyhRBqTpIWRj71OiUuNRe0zsh0QTducuQ2vLIQlCkhjM95X0SCeg y2aDnbKNim+vNFmbFHFB13PeJzT2cFPI7gqMVRkqYl1MOvaVCtxCjQ6EwlVCdCotnYIl i5L23IepFDerUoygTkvC5Sj03SeBkMCB5V/d/JjCRFzljhOmtwMWdzeL57JiSoaxll73 oJ/NlY+67DmKg8DdRL4GYBJRb1OE+ec0K4Y+EsaHpCLW0jMXJCS2qvGlxmcKnua0jEP6 pzKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b0zoFdov; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si4609555ejv.78.2020.06.19.13.27.02; Fri, 19 Jun 2020 13:27:24 -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=b0zoFdov; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390927AbgFSPDD (ORCPT + 99 others); Fri, 19 Jun 2020 11:03:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:59350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390876AbgFSPCn (ORCPT ); Fri, 19 Jun 2020 11:02:43 -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 8B50A21841; Fri, 19 Jun 2020 15:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578963; bh=vLM00da0dcPE+XpMqn8kxehxh+b2qBbY1T82WW91wwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0zoFdov4rbFAdP1zmzQrEiqpDIw70de+OGSeEvLhmpLU77OaqTlATPKAFWP9S0v4 NhoWxbGIKF/iCCX4lVA65uPtFVJ0fTTniA8HDSA6A9p+KjwFMH8LBzP8XQRtANIHR4 JhwBYW0YJyK7tKS+ShVHerx7GAJZ4ka+SyYHO8aQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiushi Wu , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.19 183/267] cpuidle: Fix three reference count leaks Date: Fri, 19 Jun 2020 16:32:48 +0200 Message-Id: <20200619141657.547951085@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@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: Qiushi Wu [ Upstream commit c343bf1ba5efcbf2266a1fe3baefec9cc82f867f ] kobject_init_and_add() takes reference even when it fails. If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Previous commit "b8eb718348b8" fixed a similar problem. Signed-off-by: Qiushi Wu [ rjw: Subject ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/cpuidle/sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index e754c7aae7f7..66979dc33680 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -467,7 +467,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device) ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &kdev->kobj, "state%d", i); if (ret) { - kfree(kobj); + kobject_put(&kobj->kobj); goto error_state; } cpuidle_add_s2idle_attr_group(kobj); @@ -598,7 +598,7 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev) ret = kobject_init_and_add(&kdrv->kobj, &ktype_driver_cpuidle, &kdev->kobj, "driver"); if (ret) { - kfree(kdrv); + kobject_put(&kdrv->kobj); return ret; } @@ -692,7 +692,7 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev) error = kobject_init_and_add(&kdev->kobj, &ktype_cpuidle, &cpu_dev->kobj, "cpuidle"); if (error) { - kfree(kdev); + kobject_put(&kdev->kobj); return error; } -- 2.25.1