Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2461161rdb; Wed, 4 Oct 2023 01:39:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEqXixg0A3sGcNjqCQYFyXbMl7tS4HK5wLY8BZ5jUPo9NLIFP+yaaBYhLi23iRD4DpffDY X-Received: by 2002:a05:6a20:3ca5:b0:13d:d5bd:7593 with SMTP id b37-20020a056a203ca500b0013dd5bd7593mr1766825pzj.12.1696408776724; Wed, 04 Oct 2023 01:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696408776; cv=none; d=google.com; s=arc-20160816; b=V9Ub3lTYHjNgmVe0sx+uvPYrhsikn9vO/+kd0SOGW/cehUfhcg7Y0NechiUx3/LDsZ JgMVvO43cY5lvF3RZqm2PI3qWhvl1CLlcPJmsB89cy2y7JAUxIgK1Q1K0lfS0wp5Mk64 m+QAx16DmsXQDv66p2zFdTKxjqKuSJ+EL77O5k015+QaSWFqn/NHh7rxhq6w1FwnAJ/p 3PNHZUG+jCyZVBXDuukNSYXuHA2OeaDt1ppdIpvhiwBP9Q9NgasYzmk+M1DtricQEsGk NMnRTicdTcriSTMxJwVcujIMtH4VKsdeoYhwMZOd9zgA4uddTlP08aWlLKyPZlyE7qej 6KlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9/MtXqLrtXt958q8e0H362E4aqBcq4uYbsSDrU1xpVo=; fh=6lQgTNsGcf4ncD/mAeeUXz9T1fmOUOo5jLz8DFHlSe4=; b=oQUJNkBc8WprNj55eBCHrbTDfwqD5NMwzeXnZRkw9MsGjjP7J7m4K9WAlzIKcIAc4a 6lIHqsjPyv7RkchsmOFNYbfwKn+fbGvfDW/zgTm7EHhE3ToRm3DMVHGLJHl4ekVvjuxp bbdWxxnLyarREdtjpiImZgouI4hTQU//RQh7fb5wskjknLP9UmVb5Lk9NcRjc0zPp7v6 1AhFCsKpSwS+2XDznqQz1IEwZe9oaJhKJKYVARi6pthrB8T/X4V/ZmFIgPmHpDgKSOGI jBs172Yy6+mwKY7W42FyMABIY63kYjM3go0sqhnpkJwIEpAbGAbFdtXA2MqhtibvxpVP MaMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PhoFhT+k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id u10-20020a170902e5ca00b001c72dbaf7b9si3688661plf.415.2023.10.04.01.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PhoFhT+k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 39F9081A4FD3; Wed, 4 Oct 2023 01:39:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241734AbjJDIjU (ORCPT + 99 others); Wed, 4 Oct 2023 04:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241722AbjJDIjS (ORCPT ); Wed, 4 Oct 2023 04:39:18 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A097A83; Wed, 4 Oct 2023 01:39:15 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3af5b26d599so1309738b6e.2; Wed, 04 Oct 2023 01:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696408755; x=1697013555; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9/MtXqLrtXt958q8e0H362E4aqBcq4uYbsSDrU1xpVo=; b=PhoFhT+k8iXZbJJWigYXQ2gDiWymPPg0UofingBuJzNZGfEwB1SwvSL6vt3eRw9FRx OZp9MLgJegcY8yDW3uWABPAFTmOJT3ZHmJfRUTyp4rh95X++ehEAEstJPFbNNsQQXgDA OoIXTN/pOSdcSa4+Exev4oUm2znAMBRN4r+LR8PtUSL06Vo52nQtuQhnmzZyMkoRaBwr RLcE+57Cqty0YMvxZzzl7dzpWxq6v6dm0uoId5YIZMgcMr3usPLBeGjwzjbBSoIXbumI wyZjnNoCQ2DY0AqaRMPGIqkae9gCa65VqB5orSg7rL2KwJMv2F7XB4wrJ6vimHbyL1C6 XxAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696408755; x=1697013555; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9/MtXqLrtXt958q8e0H362E4aqBcq4uYbsSDrU1xpVo=; b=ek3xBBikbO6Vuqr+lyakfZWzBidtq5ftM51LMN9NwFhuIsfLNKAgMOdTlRiCgf7Znk qeS0/E/l3NLbC5oEGEA2e84uePCia/6mF0QjJGwYYCrYbGLroMCN9zMvoAuPoAVZRbjN 20HtEcqETVw1sx8GAfFvRnRBDlCcpQBdOUkCI8ZYgTm0z57g682PDatR+8btlfTb/Xi+ lxkmkfwTZQOnZH6jHa067ibAS7Sf/qShmh4xL5yf0DSHDG1nDcMMNHYvo713UsFGi56I 7MBS2tVI1Ao0V0Mnn1sOmDhWgBvI5FyEbferu6Z4S4kL8aKKeTk3wMs25rV4Bvm3qVBm QwYw== X-Gm-Message-State: AOJu0Yx0r2WjNmIwJ+Q3Pig2bg7h49NFivjPnKvhr91f+LX6AZm0exnH CNsQc0b/cnF/z4070Q4DKylJPxziUlx10B2evmg= X-Received: by 2002:a05:6808:1ce:b0:3a9:6400:62c6 with SMTP id x14-20020a05680801ce00b003a9640062c6mr1734553oic.32.1696408754882; Wed, 04 Oct 2023 01:39:14 -0700 (PDT) MIME-Version: 1.0 References: <20230921073217.572151-1-alessandro.carminati@gmail.com> In-Reply-To: <20230921073217.572151-1-alessandro.carminati@gmail.com> From: Alessandro Carminati Date: Wed, 4 Oct 2023 10:38:39 +0200 Message-ID: Subject: Re: [PATCH v2] clk: Sanitize possible_parent_show to Handle Return Value of of_clk_get_parent_name To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Philip Daly Content-Type: text/plain; charset="UTF-8" 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 04 Oct 2023 01:39:32 -0700 (PDT) gentle ping In the original email, I acknowledge that I misplaced the maintainers mail addresse from the "to" field. Il giorno gio 21 set 2023 alle ore 09:33 Alessandro Carminati (Red Hat) ha scritto: > > From: Alessandro Carminati > > In the possible_parent_show function, ensure proper handling of the return > value from of_clk_get_parent_name to prevent potential issues arising from > a NULL return. > The current implementation invokes seq_puts directly on the result of > of_clk_get_parent_name without verifying the return value, which can lead > to kernel panic if the function returns NULL. > > This patch addresses the concern by introducing a check on the return > value of of_clk_get_parent_name. If the return value is not NULL, the > function proceeds to call seq_puts, providing the returned value as > argument. > However, if of_clk_get_parent_name returns NULL, the function provides a > static string as argument, avoiding the panic. > > Fixes: 1ccc0ddf046a ("clk: Use seq_puts() in possible_parent_show()") > Reported-by: Philip Daly > Signed-off-by: Alessandro Carminati (Red Hat) > --- > drivers/clk/clk.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index c249f9791ae8..473563bc7496 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -3416,6 +3416,7 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core, > unsigned int i, char terminator) > { > struct clk_core *parent; > + const char *name = NULL; > > /* > * Go through the following options to fetch a parent's name. > @@ -3430,18 +3431,20 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core, > * registered (yet). > */ > parent = clk_core_get_parent_by_index(core, i); > - if (parent) > + if (parent) { > seq_puts(s, parent->name); > - else if (core->parents[i].name) > + } else if (core->parents[i].name) { > seq_puts(s, core->parents[i].name); > - else if (core->parents[i].fw_name) > + } else if (core->parents[i].fw_name) { > seq_printf(s, "<%s>(fw)", core->parents[i].fw_name); > - else if (core->parents[i].index >= 0) > - seq_puts(s, > - of_clk_get_parent_name(core->of_node, > - core->parents[i].index)); > - else > - seq_puts(s, "(missing)"); > + } else { > + if (core->parents[i].index >= 0) > + name = of_clk_get_parent_name(core->of_node, core->parents[i].index); > + if (!name) > + name = "(missing)"; > + > + seq_puts(s, name); > + } > > seq_putc(s, terminator); > } > -- > 2.34.1 >