Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3310424imu; Sun, 11 Nov 2018 12:06:38 -0800 (PST) X-Google-Smtp-Source: AJdET5ccuyOp358LZOrZ2VyD2KW8u6Bk/SZJ/Mamx+ZORgIXdLsutdMpGT/qUJjJmjHTYBjkhrx3 X-Received: by 2002:a62:32c4:: with SMTP id y187-v6mr17465845pfy.4.1541966797960; Sun, 11 Nov 2018 12:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966797; cv=none; d=google.com; s=arc-20160816; b=eFV0M6wW46FfkxXh3iKQJaUj2hhtPPI9UjnP6Uzyy777h6iJWdLU02rgA7k0ZrioDv TjHriy8JWGeGX4VtkbFu26ID3rzFs76DKMnFG5+DMG29Joq3kXPuWgO/dmcByJKyo6m5 d5GuwuXsIBNdMjMsDYIQXwedV6+fkMfpPAjQ0xR64Nnb4sOMEmW5WyeVripyWfsTjRbp VrxX2wske49df7BSZBhXk5jE7/L1wlIMvEjkdMUMe8SG7ZaAEshYt9KI8gH+SxWCr1x3 E5gI6GkIRbgqmNMtpfklieRSFMC12h6qtt6JzA+nAF+UqDTQUNu2YgVGbfdQOF0cRFmF CcEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=99wwJckMobT2n0+QkwxopLO008Iz55Xgb+loJqCoMKI=; b=gALgK6Q4mWdc8yNc/okOjRAJRIccppaeKDIIpTUqObb7EvnnwWWDHMeIypHB1zUr2U QykuIJNFVB5egwK9HfiN9WkOwizlQ4qIs3ckz2OUrJHJujMqiaIMuGDy4NfY9szTO1mW ERSGFtMLlYBvdosQa//USssEUIqzdZIlgf7y0LwGxfJCnBoUveAzGIxo/331eq/e3Dyx TveN19BpAAGF93LaG6iA7Dn8R8lJASyxyXIr9sPIfsa8dBH49AdZxzXa5wIl08z+wbXt /L/afDr1aiX5ihhEwM+MpsAyrvmbgfyYRMPfmbkYzhv0Kmbo1jQt1iMp5ufJUD6An6Pw 78wg== ARC-Authentication-Results: i=1; mx.google.com; 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 x12-v6si15374298pfn.111.2018.11.11.12.06.22; Sun, 11 Nov 2018 12:06:37 -0800 (PST) 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; 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 S1731041AbeKLFxg (ORCPT + 99 others); Mon, 12 Nov 2018 00:53:36 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51618 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726637AbeKLFxf (ORCPT ); Mon, 12 Nov 2018 00:53:35 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvt8-0000oO-Ka; Sun, 11 Nov 2018 19:59:18 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsP-0001S4-Sy; Sun, 11 Nov 2018 19:58:33 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Rob Herring" , "Frank Rowand" , "Stefan M Schaeckeler" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 075/366] of: unittest: for strings, account for trailing \\0 in property length field In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Stefan M Schaeckeler commit 3b9cf7905fe3ab35ab437b5072c883e609d3498d upstream. For strings, account for trailing \0 in property length field: This is consistent with how dtc builds string properties. Function __of_prop_dup() would misbehave on such properties as it duplicates properties based on the property length field creating new string values without trailing \0s. Signed-off-by: Stefan M Schaeckeler Reviewed-by: Frank Rowand Tested-by: Frank Rowand Signed-off-by: Rob Herring [bwh: Backported to 3.16: s/unittest/selftest/] Signed-off-by: Ben Hutchings --- drivers/of/selftest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/of/selftest.c +++ b/drivers/of/selftest.c @@ -97,20 +97,20 @@ static void __init of_selftest_dynamic(v /* Add a new property - should pass*/ prop->name = "new-property"; prop->value = "new-property-data"; - prop->length = strlen(prop->value); + prop->length = strlen(prop->value) + 1; selftest(of_add_property(np, prop) == 0, "Adding a new property failed\n"); /* Try to add an existing property - should fail */ prop++; prop->name = "new-property"; prop->value = "new-property-data-should-fail"; - prop->length = strlen(prop->value); + prop->length = strlen(prop->value) + 1; selftest(of_add_property(np, prop) != 0, "Adding an existing property should have failed\n"); /* Try to modify an existing property - should pass */ prop->value = "modify-property-data-should-pass"; - prop->length = strlen(prop->value); + prop->length = strlen(prop->value) + 1; selftest(of_update_property(np, prop) == 0, "Updating an existing property should have passed\n"); @@ -118,7 +118,7 @@ static void __init of_selftest_dynamic(v prop++; prop->name = "modify-property"; prop->value = "modify-missing-property-data-should-pass"; - prop->length = strlen(prop->value); + prop->length = strlen(prop->value) + 1; selftest(of_update_property(np, prop) == 0, "Updating a missing property should have passed\n");