Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4623011rdh; Wed, 29 Nov 2023 06:34:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpuIUFpeIBd7sIeS3uif2d/DJBTyBDQ1I7caxjtZ6uTBYi+rC/YtlNure7Li7Uukh+Op7e X-Received: by 2002:a05:6808:1486:b0:3b8:5c93:e072 with SMTP id e6-20020a056808148600b003b85c93e072mr18369714oiw.44.1701268495788; Wed, 29 Nov 2023 06:34:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701268495; cv=none; d=google.com; s=arc-20160816; b=AX0bk5gN/wQb6fKxRYk77HhtSkG1vaKD5uNNfLtEBipVU8IJqmDMqNIy31DlTkxkIa NSWvRrgLKNW0oWbBAahQ9LB/CaS/qBPHQq0+OS+AwbVHRpBCh0sQbkNuB8v7U/iNsjua wYoOcTuCB5GTwNIW6R4opik3ZhQNSTxS7t70djdl2VY1ymG5mhZQY+h7OxaAW/vKugs2 1dnaMAJRDSxxoJ/RNKL5sXgkWQxKUIj90pKTxjVFipEiT9DqdBHpHDBGQMJzDu7TiJo9 /eRJ0SpaNMPhu5wRxXhITjKLrW8f5biKWaGA0vL7HDh6k5niXTFTtx8bOJaSXAwMsKPY Bo/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=5srYGa010zaXPgeYMU4ezpiryKXspoRb2NGozsAbp6M=; fh=PH8y6Z+eTnuhV/HqyQ/cRbI80l4EwMPiQGGR2bwMVmY=; b=Xg7IFrjWgWveo68nsDug/IrGH9Xjmrj51TOPcrf7cm6DlALnKBP/p58nRX6NnLoYKV 1Nb+gce7T3rmJG67BhZfcZ2P2eFrahvrRkRu7uGYtTTRyqEXQ4vzLhiUtGQICXZhDMe7 rrBlj+Y0eBasq6jW1mkv2cb/F4QVUsJjwcK3w7ED9tH+u/UIq3yRNBWwq4tFfgGT3spT 3IfEXSloxZA0fFGGWN014MTSMZ4TOtK3y1pOKfpK8QgMF8WhqiOApa5hn75YV6xRWLGX 7G/PywQpMg6Qur63jcK6WKrPFMsmLHwCRh62q1JPdaJYtUcyzK0BAjjF8WxPAyyW7DmJ 82aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=RixMxYKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c19-20020a630d13000000b00563deb65f93si14469174pgl.200.2023.11.29.06.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 06:34:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=RixMxYKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 63BFF80417DF; Wed, 29 Nov 2023 06:34:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234297AbjK2Oei (ORCPT + 99 others); Wed, 29 Nov 2023 09:34:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231195AbjK2Oeg (ORCPT ); Wed, 29 Nov 2023 09:34:36 -0500 Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D6D5219A; Wed, 29 Nov 2023 06:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=5srYGa010zaXPgeYMU 4ezpiryKXspoRb2NGozsAbp6M=; b=RixMxYKO/qJUdWCkylWy7m/RrTLJBq9eJj aXSL4WVeIjysSLrAZh0qTpmO7IaUu5XXTf3QFwR+I/QRqkbaPGmz4M76jKReCB8p cmynjGx3JagnSaslOPwFtPxDC7zAG8R2VbdXD89oPT5LcPDDf39X+t1ABWBztoFb SlWR2Kygg= Received: from localhost.localdomain (unknown [39.144.190.126]) by zwqz-smtp-mta-g1-2 (Coremail) with SMTP id _____wCn7274S2dl2svTAQ--.48522S2; Wed, 29 Nov 2023 22:34:34 +0800 (CST) From: Haoran Liu To: geert+renesas@glider.be Cc: magnus.damm@gmail.com, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Haoran Liu Subject: [PATCH] [soc/renesas] renesas-soc: Add error handling in renesas_soc_init Date: Wed, 29 Nov 2023 06:34:31 -0800 Message-Id: <20231129143431.34459-1-liuhaoran14@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: _____wCn7274S2dl2svTAQ--.48522S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7KF17KFy8ZrW7GryfKr4DJwb_yoW8WFWrpa 1kCws8AryUG3WxZ39xGa1xZ3WSya18KrWSkr1DKwn7u3WrXFyUtF12vFyY9r1UWFWv93WY qF4Uu345Ar1UCFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pR9a9xUUUUU= X-Originating-IP: [39.144.190.126] X-CM-SenderInfo: xolxxtxrud0iqu6rljoofrz/xtbBcgM3gletj5Wr-wAAsw X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 06:34:53 -0800 (PST) This patch enhances the renesas_soc_init function in drivers/soc/renesas/renesas-soc.c by adding error handling for the of_property_read_string call. Previously, the function did not check for failure cases of of_property_read_string, which could lead to improper behavior if the required device tree properties were missing or incorrect. Although the error addressed by this patch may not occur in the current environment, I still suggest implementing these error handling routines if the function is not highly time-sensitive. As the environment evolves or the code gets reused in different contexts, there's a possibility that these errors might occur. Addressing them now can prevent potential debugging efforts in the future, which could be quite resource-intensive. Signed-off-by: Haoran Liu --- drivers/soc/renesas/renesas-soc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/soc/renesas/renesas-soc.c b/drivers/soc/renesas/renesas-soc.c index c732d4a5b26a..7a5f5c426118 100644 --- a/drivers/soc/renesas/renesas-soc.c +++ b/drivers/soc/renesas/renesas-soc.c @@ -487,7 +487,13 @@ static int __init renesas_soc_init(void) } np = of_find_node_by_path("/"); - of_property_read_string(np, "model", &soc_dev_attr->machine); + ret = of_property_read_string(np, "model", &soc_dev_attr->machine); + if (ret) { + dev_err(dev, "Failed to read model property: %d\n", ret); + kfree(soc_dev_attr); + return ret; + } + of_node_put(np); soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); -- 2.17.1