Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp898599pxp; Wed, 16 Mar 2022 20:35:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPo6To1SVPQyWx61YYecVNc/CbR1M+yectHgiOld+e2B5U/tvGy2APEzujFaqbWLcQBYNB X-Received: by 2002:a17:90a:a594:b0:1bc:5def:a652 with SMTP id b20-20020a17090aa59400b001bc5defa652mr3014706pjq.167.1647488103878; Wed, 16 Mar 2022 20:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647488103; cv=none; d=google.com; s=arc-20160816; b=m2nP6giTjb2dWO2jpEYlmCGxm8f6LnKEbL9wskf8OV7iahlbTefqc+uzi9JI7jFhkD /1oUusUbwOplwPACj1LH9XceKAu4hTfUGgY8Wv4JiGHHQOgF7vqtoeHOOXPizrSA++qe 98BSmnK4TOrnVVCSN++//TEaAJ0N1t7w/clYHWPdb0ctHHyHSc0TiIj6Y9+zxI0VYBxq o8P7NIcKwkdMb2/cfq2wb/4nevYgljW4SsF1s74spTuEeEnfnGADZcrPdxIf9aWfuZYz mXOiU6KaBHpV53i6ImAJNf5lMbU3la0IEhLJhq/VlpHpIm6o1pFUiQUuaDOkAO5jFw0r Ng5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:date:to:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=QEgoGKJ5owt3XqgGtHHGyogRPAGmQFMzILWXTKE3R2g=; b=atoh9BFSoIibG02n6PrvuRJYzshpf4daMRxZHIHSR8VMppOeX2AQdMhxV19TEx7NEf NLZGDsERBVx+DbZrZAnyw/UFbdGR32zxQRN/TQbBqk5eatetO+/6pOTjBthfsSJWUrLo YF8eaQ1Q5AMIWZvfzpjOwipfX4BOHP4TMidnbDVO0/V6IgWxm0lccFn4K/vDp0SPCrCo BoISxJNaHo1H8qWl8PW6TaNJ7tR6aazCfoZvrMvjonsFFefi2XYjveWniXATkoBpVA/L juNkQbSGlajXzIW+hIlWKuk1Fxym79yi9T+WiTWZ9Sl+zjPt7sVZPO8WXfRfsUTFTVj+ DPBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pcS+qJ/N"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z4-20020a631904000000b003816043f14dsi877099pgl.834.2022.03.16.20.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:35:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pcS+qJ/N"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 813FB49F8A; Wed, 16 Mar 2022 20:30:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352320AbiCOWo4 (ORCPT + 99 others); Tue, 15 Mar 2022 18:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242472AbiCOWoy (ORCPT ); Tue, 15 Mar 2022 18:44:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F002FFD12; Tue, 15 Mar 2022 15:43:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1FF8FB818FA; Tue, 15 Mar 2022 22:43:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB736C340E8; Tue, 15 Mar 2022 22:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647384218; bh=QcYqmC9EtcqrxIXAjr3U5b4uFH7SGAQ/mzDiG0FRn88=; h=In-Reply-To:References:Subject:From:To:Date:From; b=pcS+qJ/NUP5uIYob7rCZmQgzM8idpH+biefZhodEeNpEP/LWGX2K469apAdR2FgbS qJ9hDDiNFRcwC86APpuFR+zx1kxCd5iENiMwd/GgWEBeRb1RJCE6gbmDmDCjyjB6pV daUsUvY8vjUNZKAAySKZT53TTJ7zDsQj6E664mfBKafOj76kbk7brY6qgJEbGyxXKh sEdVKDIecb5RCpi3tKi2NsAwzKx+I9I9Jb0nmKsz/f37xeOo1ywlF6wMPBQVUpDtc+ QpWlCwYk+xSSKNSl0d2U43Ooq3two8n3HYOBP53AooJ3NTMgY/OqZ/9s/aCm0wqoOV 6BOTd9z19URkA== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20220313190419.2207-8-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> <20220313190419.2207-8-ansuelsmth@gmail.com> Subject: Re: [PATCH 07/16] clk: qcom: clk-krait: add hw_parent check for div2_round_rate From: Stephen Boyd To: Andy Gross , Ansuel Smith , Bjorn Andersson , Jonathan Hunter , Michael Turquette , Peter De Schrijver , Prashant Gaikwad , Rob Herring , Thierry Reding , devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Date: Tue, 15 Mar 2022 15:43:36 -0700 User-Agent: alot/0.10 Message-Id: <20220315224338.BB736C340E8@smtp.kernel.org> X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Ansuel Smith (2022-03-13 12:04:10) > Check if hw_parent is present before calculating the round_rate to > prevent kernel panic. >=20 > Signed-off-by: Ansuel Smith > --- > drivers/clk/qcom/clk-krait.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/clk/qcom/clk-krait.c b/drivers/clk/qcom/clk-krait.c > index e447fcc3806d..d8af281eba0e 100644 > --- a/drivers/clk/qcom/clk-krait.c > +++ b/drivers/clk/qcom/clk-krait.c > @@ -80,7 +80,12 @@ EXPORT_SYMBOL_GPL(krait_mux_clk_ops); > static long krait_div2_round_rate(struct clk_hw *hw, unsigned long rate, > unsigned long *parent_rate) > { > - *parent_rate =3D clk_hw_round_rate(clk_hw_get_parent(hw), rate * = 2); > + struct clk_hw *hw_parent =3D clk_hw_get_parent(hw); > + > + if (!hw_parent) > + return -1; Use -EINVAL or some proper error code, not just -1 > + > + *parent_rate =3D clk_hw_round_rate(hw_parent, rate * 2); > return DIV_ROUND_UP(*parent_rate, 2); > } > =20 > --=20 > 2.34.1 >