Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2463329imm; Mon, 28 May 2018 08:32:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqZNzrPgTEClzYxeEKELyVDnd0qSfH6DraMZhLHav5Ofz/nLBqeILKf7qogtcGyTHmhcptA X-Received: by 2002:a63:7553:: with SMTP id f19-v6mr11173078pgn.314.1527521555894; Mon, 28 May 2018 08:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527521555; cv=none; d=google.com; s=arc-20160816; b=mbtOY/dR7HRRq8h8tyvPXv++Ry/eSaSsqXGz0pWdBoQ3ZrAL4CXpVLQsbwuFapO1OH zqjj3jhmGwKpbao9Bbrfhja5psMY53ZJVMQNV8AM2mhgu+5vMKgAh0CbLRs1ZpNMAVZ9 91NmYwWX6yEfjY5jXu0EQnrQkP5eruxIfYQLDRdw+sKverQzOHSuV5qbECqWpmtq4lmI DVu0ywj37ZOiTsAkOstzxPwmOIrZnwGzQSdZmyWpMMV2CtNleD6hnzGozZVzcFICWCIy teMwoGtk14V0KP5AkEU2w1N8rYV3pZmm0oyUv/UTk+glEaJxxHq5J1huDHYd7XILE3Cp K2AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=XGWu3tFBg7wBGGWfSL61vK1fxrEJmHXlGMpQ3k0ntvs=; b=h5+mZZtBkKz1OP50Is66L6urQFG5AWbaIa0x9xBVxjOUP5HbIpeFHB4ffQVFpulHlA a9JuUhcFVAfkxtRIF2n9MErmn0koBxu3z9Cyl6fNy4NoVX27vvcQslKaV6ft4Cmswy3L skYg/KgSXY5JuC1HkZdT0Z5Ruv8IvVRkR4Tw2Whld+XhgxiSrNjy+z7u6l2GBrJiUAsC 6uewGp0BkSclovWW9hc1xlNPZpemS4mURcGGWyKrfjFRs+nvp0CStrUfNDHqm0zaTx5t +8KdLJO/F57KVW7BrV/l0Hske2ytYjsbuT5JBQoSNN19C5BxUSHBbqM0ZwDlHPHfau6d hyRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OiCmIioC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8-v6si33275991pli.75.2018.05.28.08.32.21; Mon, 28 May 2018 08:32:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OiCmIioC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033404AbeE1Pbf (ORCPT + 99 others); Mon, 28 May 2018 11:31:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:39194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936859AbeE1KTM (ORCPT ); Mon, 28 May 2018 06:19:12 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 3273B206B7; Mon, 28 May 2018 10:19:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502751; bh=jcXkRdH75m3Uw+HxiMFIB8xsvRd+z0OMNG4yM8kmx9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OiCmIioCvlFW8P8w9NYzmwnXjTrLTs9o03vXeCBVFu8vWblWk9HnxrDJlRPGtqNNs dUnXt7cX/5XdEltpDJgbvT+egg4QAAVsl5R9KoHCAPgP1gcO6vSrb3sE70vWSMsKjW W58UgbYsNxrAkxCJdP/z+jc+eTAaiyqInCXX0QGQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qi Hou , Tony Lindgren , Sasha Levin Subject: [PATCH 4.4 085/268] ARM: OMAP2+: timer: fix a kmemleak caused in omap_get_timer_dt Date: Mon, 28 May 2018 12:00:59 +0200 Message-Id: <20180528100211.769763873@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qi Hou [ Upstream commit db35340c536f1af0108ec9a0b2126a05d358d14a ] When more than one GP timers are used as kernel system timers and the corresponding nodes in device-tree are marked with the same "disabled" property, then the "attr" field of the property will be initialized more than once as the property being added to sys file system via __of_add_property_sysfs(). In __of_add_property_sysfs(), the "name" field of pp->attr.attr is set directly to the return value of safe_name(), without taking care of whether it's already a valid pointer to a memory block. If it is, its old value will always be overwritten by the new one and the memory block allocated before will a "ghost", then a kmemleak happened. That the same "disabled" property being added to different nodes of device tree would cause that kind of kmemleak overhead, at least once. To fix it, allocate the property dynamically, and delete static one. Signed-off-by: Qi Hou Signed-off-by: Tony Lindgren Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-omap2/timer.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c @@ -136,12 +136,6 @@ static struct clock_event_device clockev .tick_resume = omap2_gp_timer_shutdown, }; -static struct property device_disabled = { - .name = "status", - .length = sizeof("disabled"), - .value = "disabled", -}; - static const struct of_device_id omap_timer_match[] __initconst = { { .compatible = "ti,omap2420-timer", }, { .compatible = "ti,omap3430-timer", }, @@ -183,8 +177,17 @@ static struct device_node * __init omap_ of_get_property(np, "ti,timer-secure", NULL))) continue; - if (!of_device_is_compatible(np, "ti,omap-counter32k")) - of_add_property(np, &device_disabled); + if (!of_device_is_compatible(np, "ti,omap-counter32k")) { + struct property *prop; + + prop = kzalloc(sizeof(*prop), GFP_KERNEL); + if (!prop) + return NULL; + prop->name = "status"; + prop->value = "disabled"; + prop->length = strlen(prop->value); + of_add_property(np, prop); + } return np; }