From patchwork Wed Jul 29 14:51:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 1338349 X-Patchwork-Delegate: eugen.hristev@microchip.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=C4QROpd9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BGxMm5yN2z9sRX for ; Thu, 30 Jul 2020 00:52:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D8190821F8; Wed, 29 Jul 2020 16:51:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=microchip.com header.i=@microchip.com header.b="C4QROpd9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8E70825D0; Wed, 29 Jul 2020 16:51:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa5.microchip.iphmx.com (esa5.microchip.iphmx.com [216.71.150.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A4CF1821F8 for ; Wed, 29 Jul 2020 16:51:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=Claudiu.Beznea@microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1596034311; x=1627570311; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=SEq6viWc2J0ugtKPdRuFF+uKLiwOgHl/phMRBbXg13k=; b=C4QROpd98WJX9mV3ZKb5Boh/ecMuUsDIhJLAOblwnqHHdOVX/mOHG5r4 nXEFcIrG0hvyHfyopDnIYGFT0TFANlabtWWf/8L8QDA7jeEI7bcSuzsHp 2jGXlcTMqGD7c6+nhIRiLuuF+Ih7bttzq7pRlK6p5MIpuUey2Yo98C4XF KPXzUo7D94SaSz9KHNreurF8RxiEaHvGyH4r6b0xMBJjQIBgSi4ks+N4v GiFt3luIqH7pM4iUTcMkSsBRprKTqfpleOL4DwJ10ia35FFfLC9Skds7z db0oAblCn6OI33SY5x8KDhsdQMQVqE8oAX1m/GUkiiFdaq+AEg865Q+Qg g==; IronPort-SDR: DtVZYKiO3i7IBnOZpUz4KBKgPvxdxeWvxHYq/0kmQfJ/KsFNrL9G40QBqHi8DWvVUylvRSWl/I t992cZydjEpYSJwxHuthdqUImZDDe3vOXjfMwRyPBDx6dnKMQ6JHw8aqXzpqKII2+XQVIWQcA4 1mSIfPMSgo/usBpf5oaI7wZ3Rh+9IC+9nEG9gxrGdgOxuQ/mHgbwoHqBY7h4lxRVH/VkYnm1he cnEcdIo9lbvKnX5rUjHbQwRSIjvRF4jMcBReqqdEtHYxMpRuFx7L1aVPoEdJh0Q9f41osMLH0i CsY= X-IronPort-AV: E=Sophos;i="5.75,410,1589266800"; d="scan'208";a="85035812" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 29 Jul 2020 07:51:49 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 29 Jul 2020 07:51:46 -0700 Received: from m18063-ThinkPad-T460p.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 29 Jul 2020 07:51:44 -0700 From: Claudiu Beznea To: , CC: , Subject: [PATCH 01/22] clk: check hw and hw->dev before dereference it Date: Wed, 29 Jul 2020 17:51:20 +0300 Message-ID: <1596034301-5428-2-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596034301-5428-1-git-send-email-claudiu.beznea@microchip.com> References: <1596034301-5428-1-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Check hw and hw->dev before dereference it. Signed-off-by: Claudiu Beznea --- drivers/clk/clk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0f55ba751c0f..9fa18e342eaf 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -57,6 +57,9 @@ ulong clk_generic_get_rate(struct clk *clk) const char *clk_hw_get_name(const struct clk *hw) { + if (!hw || !hw->dev) + return NULL; + return hw->dev->name; }