From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claudiu.Beznea at microchip.com Date: Tue, 4 Aug 2020 07:19:29 +0000 Subject: [PATCH 02/22] clk: check pointer returned by dev_get_parent() In-Reply-To: References: <1596034301-5428-1-git-send-email-claudiu.beznea@microchip.com> <1596034301-5428-3-git-send-email-claudiu.beznea@microchip.com> Message-ID: <641e97d0-490a-776e-1a98-a708846e55a7@microchip.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 04.08.2020 05:00, Simon Glass wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > Hi Claudiu, > > On Wed, 29 Jul 2020 at 08:51, Claudiu Beznea > wrote: >> >> Check pointer returned by dev_get_parent(). >> >> Signed-off-by: Claudiu Beznea >> --- >> drivers/clk/clk-uclass.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c >> index 70df9d410f4c..aa1f11a27c41 100644 >> --- a/drivers/clk/clk-uclass.c >> +++ b/drivers/clk/clk-uclass.c >> @@ -459,6 +459,9 @@ struct clk *clk_get_parent(struct clk *clk) >> return NULL; >> >> pdev = dev_get_parent(clk->dev); >> + if (!pdev) >> + return ERR_PTR(-ENOMEM); > > A clock device must always have a parent (e.g. the root device). So > this check is not useful and adds to code size. Sure, I'll remove it. > >> + >> pclk = dev_get_clk_ptr(pdev); >> if (!pclk) >> return ERR_PTR(-ENODEV); >> -- >> 2.7.4 >> > > Regards, > Simon >