From patchwork Fri Aug 4 22:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 710348 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C419DC001DB for ; Fri, 4 Aug 2023 22:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230159AbjHDWmc (ORCPT ); Fri, 4 Aug 2023 18:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230181AbjHDWm3 (ORCPT ); Fri, 4 Aug 2023 18:42:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 220035249; Fri, 4 Aug 2023 15:42:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 988F362179; Fri, 4 Aug 2023 22:42:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EDEEC433BA; Fri, 4 Aug 2023 22:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691188942; bh=8peVQkAUMgH6YYwSmql7OBIk0sITKpX/yuaqGHaDXB4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=J08bLM+ZIWZyOUIzecJOud+FY5i8wr9eDNnSKKs8j8Lt6897mCjFm3GwPUBlT4b5B QmvBd/vCnAOoj/14mm6KDcbgd3IuPxp1BNtG4F2L6Gw0SUa7+0MfKGAkeL5MB1/PEm 8+Mg25fqrvIqw4ICodp4w/CD2bdTNuIonurUPuAVenTaWAwTZUXzfSRC0Nxu5h/SOs oMj/243kUx2DYjVmY7uNpZJgb9KsQSCDEU//q5rBKLXNnD/Af3odc9UB3/HzWHqF/e Fgdk7yKx1YlB3fJrA5X5pS1yxm8BRiwkrU348u/p8Wq7b3yiFPWNr3u8ABOQtCs+JF gNYURO1nv1EFg== Received: (nullmailer pid 2346981 invoked by uid 1000); Fri, 04 Aug 2023 22:42:09 -0000 From: Rob Herring Date: Fri, 04 Aug 2023 16:41:54 -0600 Subject: [PATCH v2 4/6] of: dynamic: Fix race in getting old property when updating property MIME-Version: 1.0 Message-Id: <20230801-dt-changeset-fixes-v2-4-c2b701579dee@kernel.org> References: <20230801-dt-changeset-fixes-v2-0-c2b701579dee@kernel.org> In-Reply-To: <20230801-dt-changeset-fixes-v2-0-c2b701579dee@kernel.org> To: Frank Rowand , "Enrico Weigelt, metux IT consult" , "Rafael J. Wysocki" , Sakari Ailus , Petr Mladek , Andy Shevchenko , Geert Uytterhoeven Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org __of_update_property() returns the existing property if there is one, but that value is never added to the changeset. Updates work because the existing property is also retrieved in of_changeset_action(), but that is racy as of_changeset_action() doesn't hold any locks. The property could be changed before the changeset is applied. Signed-off-by: Rob Herring --- drivers/of/dynamic.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 6eaa66b11a02..fbc7c29896a2 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -563,7 +563,7 @@ static int __of_changeset_entry_notify(struct of_changeset_entry *ce, static int __of_changeset_entry_apply(struct of_changeset_entry *ce) { - struct property *old_prop, **propp; + struct property **propp; unsigned long flags; int ret = 0; @@ -603,7 +603,7 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce) } } - ret = __of_update_property(ce->np, ce->prop, &old_prop); + ret = __of_update_property(ce->np, ce->prop, &ce->old_prop); break; default: ret = -EINVAL; @@ -904,9 +904,6 @@ int of_changeset_action(struct of_changeset *ocs, unsigned long action, ce->np = of_node_get(np); ce->prop = prop; - if (action == OF_RECONFIG_UPDATE_PROPERTY && prop) - ce->old_prop = of_find_property(np, prop->name, NULL); - /* add it to the list */ list_add_tail(&ce->node, &ocs->entries); return 0;