Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3062149imm; Sun, 1 Jul 2018 11:21:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcgaFb8CYoNt8ggY/zmzDoHPo9tPyuAdRIwzX5sNyEI5AQvZih8Q9S+ZPxrar68EuMyI2dQ X-Received: by 2002:a62:c410:: with SMTP id y16-v6mr8440624pff.161.1530469264697; Sun, 01 Jul 2018 11:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530469264; cv=none; d=google.com; s=arc-20160816; b=IXs3AlU3Yn/PhYNKiHh280xG2NbnMinlbgxdoh9c8L4sKl20Mwfy9YT3xuyelUZ7S0 zdAP9XB8K4r5UUTcm7udFPIIJ17VzQl08V+H3o40uLOzTWwvqr3KQq0KWe/e2CmCR2Su eHhMwV4UmXektSZEDqnFTJ/dhzzGPar5SbYgNEFH/66tUiuF0LJVGjWXiZJ2/1nqxYIJ w6ejJxP7B3c+SCr3WBIIvGgLGLEAt+biqZUxri6lT4l6LgaypeopXR3hexqWFIGPcoqy 6Ao0DTHDMjEGj9jDlbCfQG3fJp5tm69Hz/g5gqs2UDb9bAvMkgZ88567boo+NcF5i3+G fpOQ== 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 :arc-authentication-results; bh=69/3qSg8Ywpe0Ail0ioSYniQ0h2vH5sAyNS7OfJ1HE4=; b=QeoCensVTbalmEEiekkKLz9yFy7zNYqGjZozxavh4pF/0ZSiizao7wMLsWyPDR9hEp SN58VBtSvN0BQ8Oohq478TChVssHjgVrmNLac2jIsQ+Caee+PSxGF0jBqsPHC6YqaIaP SRVi+C0r46aI0kWZO4ESU7cS+tQd0QA2yMghj1v2O8ESIbw1/PG1SZ4vRrl0U/+Gnh56 snaA/5367/l7ev0tBQs2MKR8oCAIHILJ89ZTh182mvD5ZsaKariTLfH8dT4+qcqChER9 oIzj+UsBOfKtzgpH1xlyUS228VX5KnovxWxmqSptz4xESw2obLpJkSuygDeglhrfXw2z K61A== 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 g38-v6si7140140plb.262.2018.07.01.11.20.50; Sun, 01 Jul 2018 11:21:04 -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; 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 S1753587AbeGAQZm (ORCPT + 99 others); Sun, 1 Jul 2018 12:25:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33706 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753581AbeGAQZi (ORCPT ); Sun, 1 Jul 2018 12:25:38 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3461AAF3; Sun, 1 Jul 2018 16:25:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan M Schaeckeler , Frank Rowand , Rob Herring Subject: [PATCH 4.9 033/101] of: unittest: for strings, account for trailing \0 in property length field Date: Sun, 1 Jul 2018 18:21:19 +0200 Message-Id: <20180701160758.492523310@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@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.9-stable 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 Cc: Signed-off-by: Rob Herring Signed-off-by: Greg Kroah-Hartman --- drivers/of/unittest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -155,20 +155,20 @@ static void __init of_unittest_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; unittest(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; unittest(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; unittest(of_update_property(np, prop) == 0, "Updating an existing property should have passed\n"); @@ -176,7 +176,7 @@ static void __init of_unittest_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; unittest(of_update_property(np, prop) == 0, "Updating a missing property should have passed\n");