Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3006057imm; Sun, 1 Jul 2018 10:08:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcymaIr4vzfNgpXdVzc2PF/iN/Z2K3PmSePrzsUQGRWjgWuLba5j+s+lZGQQXDeIIQce5Pz X-Received: by 2002:a65:5545:: with SMTP id t5-v6mr18259407pgr.157.1530464938262; Sun, 01 Jul 2018 10:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464938; cv=none; d=google.com; s=arc-20160816; b=Nwvc8AGZlzoOEL3tPB2mJZyXcRh3V+NvaHtclyaGVF2Jwf2OHhzcIGKKfa1kiILv9P iAliZ0VFNJZE6zcMVat2EpdjXaRG55KnR5wImt6jZWBFnFraN9WziDdtcvkKVqZLA9Re UAHeMd6uzQ6HKPuZkVinoZqZkLbhIa97FppwlHLC56tqIeVZXiSpdV0lMJxvquE5Zfhk QNUiD9bAaQU9+UMC6xpxX7Y35aPQz8xjQXkLbpR2GbMnl1TdujWxMkt5FlZwIkYfWhhp DApNVa2vzjfMbuZ745rWSWnmcmxNptBe0fvGZFahe9f2cVh7DloKkuL9d+lcpJYeiIMl mlPA== 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=iUxQtS2bFZvAL5pBUhl3n6mLULdJU8FXbi85hYsGWK0=; b=Yi5AfsaCkNdQFA4Vr2x6kwva6p1NhY4vScLXFjpKeejaifOExQEOjGKhXbsbF4UL7Z fgKbnlQIm0ZDQSypWlbGBwsKW/QVWW7C6lXXWjHpAQLZsZgiql5IbPCAuGRIlOxrTnVq FdlOCk6fEuh7ihE1yXx+vzTvic3CncauJtgkSDcNF+uRHgmTejh8kIsxLNEc0lRZrOZS KsBg+CX9mhldz+FVhfqhNqtdIvnyc+MisePNbeQ15jEiwAxXuAB/n8pEZTLYDr3KwW9i HGnBCti15NP7LFmLh5oZ3Aw+CcfMs2Pm8iA0RZOEfPVRtcoWgaWx7JoDI7DjGv2uJTmL RKpQ== 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 a20-v6si250038pgb.600.2018.07.01.10.08.43; Sun, 01 Jul 2018 10:08:58 -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 S1032109AbeGAQlx (ORCPT + 99 others); Sun, 1 Jul 2018 12:41:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37444 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031615AbeGAQls (ORCPT ); Sun, 1 Jul 2018 12:41:48 -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 566F9ACC; Sun, 1 Jul 2018 16:41:47 +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.17 079/220] of: unittest: for strings, account for trailing \0 in property length field Date: Sun, 1 Jul 2018 18:21:43 +0200 Message-Id: <20180701160911.740952193@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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.17-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 @@ -165,20 +165,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"); @@ -186,7 +186,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");