Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2910911yba; Mon, 22 Apr 2019 15:32:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWslVRboDOOVYYbVTiXFFsabRYzWGxWdUl0mWwvgvvF7u8kNyo8eau3PJszYc/TYCsZdGz X-Received: by 2002:a65:6150:: with SMTP id o16mr21395617pgv.285.1555972330741; Mon, 22 Apr 2019 15:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555972330; cv=none; d=google.com; s=arc-20160816; b=kf7eWmvsntYPmpIwDicLHM7z+fUygQV+dlQbg4ym5WgUqiEBInksRlSxSnNySrhYka exvgW6VnZiaNXjFci/mjxJk8INAOWUEoyrXOPmmHnbFhsNgh//kkaTl+mBk4YnG7bvyF N3NRUuySuHkdnsO1kEKMUnHwu2cbGi14dMOc3VelgzZekUwNoFyxgmhyFVBWYkINVt4x lrRZ/qAWKa0qAXrzJtenXERZ3nz9nN/PC7CtLsLYKON1UCGxYpYU0zYskEtlBOsyFIy6 SkZ3CmxTdpbxRyFs85n6dBkqj97IiW7ailKhEWQirBj7QVhzRc5u/urZkJyfskwCbWoT AFGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vco9OOKrS0VVqWSlYU3sgEmzqI5gS2mdcX19bn0u9+k=; b=HSzQWKxyHNdr8vTlIHBxisXApaBikrAqvkpsJVFN/0trjcTo6KxeCDf7qkAvQ+++3B jYF4NYO+YYNSTNqi610GXEYLbsdp+OpcFuOu4Xy3cnbZTOmnj/jdj2YUzLEeR0piqg9m XKmbu43jhLdnhPmSEFUEbAquZibldkkmb9IR7iGclgdUqXFAxWbzQWcSZQkJ8+8D0ZXt GfOqBpgV2qBxAK5Iea4b75fRFMS+1tdJeRgD+DuE4rn/P1tELo2dfKQMLzxhJcKPercN OIuoT9qJ0Dq7b19xmWZD1x8g3P2SSCaHHMqLbF9NYXvcoxEpYmaqJoc0eTI6LfFW4O3K AXfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yxDvzh2D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y29si13731848pgk.120.2019.04.22.15.31.55; Mon, 22 Apr 2019 15:32:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yxDvzh2D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730037AbfDVTql (ORCPT + 99 others); Mon, 22 Apr 2019 15:46:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728669AbfDVTqi (ORCPT ); Mon, 22 Apr 2019 15:46:38 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B65D1218B0; Mon, 22 Apr 2019 19:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962397; bh=bxwBi9xthscFx/8BWKpEfnRIk6UPXuG3S0uNBv4ah34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yxDvzh2DXVxm2W9itmkL8BXARJ1kqHpnxmZ+AzuRU0mj/FHof+aXxE4hcIgiRZ4s2 shILVXMOy3iTtml4c7MJ1RElWRXQdiQ+OFUiI/+0bfXE+86Ae+svzsc2/QgOgQFsnh mTM5S1jt2uJzj0pAlgB5e3zVrbJkwDYNNrVJoeg0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Harini Katakam , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 35/68] net: macb: Add null check for PCLK and HCLK Date: Mon, 22 Apr 2019 15:44:43 -0400 Message-Id: <20190422194516.11634-35-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Harini Katakam [ Upstream commit cd5afa91f078c0787be0a62b5ef90301c00b0271 ] Both PCLK and HCLK are "required" clocks according to macb devicetree documentation. There is a chance that devm_clk_get doesn't return a negative error but just a NULL clock structure instead. In such a case the driver proceeds as usual and uses pclk value 0 to calculate MDC divisor which is incorrect. Hence fix the same in clock initialization. Signed-off-by: Harini Katakam Signed-off-by: David S. Miller Signed-off-by: Sasha Levin (Microsoft) --- drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 8abea1c3844f..7d7b51383adf 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3323,14 +3323,20 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, *hclk = devm_clk_get(&pdev->dev, "hclk"); } - if (IS_ERR(*pclk)) { + if (IS_ERR_OR_NULL(*pclk)) { err = PTR_ERR(*pclk); + if (!err) + err = -ENODEV; + dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); return err; } - if (IS_ERR(*hclk)) { + if (IS_ERR_OR_NULL(*hclk)) { err = PTR_ERR(*hclk); + if (!err) + err = -ENODEV; + dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); return err; } -- 2.19.1