From patchwork Wed Jun 15 11:30:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 583585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2E0CC43334 for ; Wed, 15 Jun 2022 11:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348065AbiFOLdK (ORCPT ); Wed, 15 Jun 2022 07:33:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345296AbiFOLdF (ORCPT ); Wed, 15 Jun 2022 07:33:05 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3112C433B0; Wed, 15 Jun 2022 04:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1655292785; x=1686828785; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=J2xeVFHRhS32YajK2SQJsuNx2FZegiEhlRercXHKr34=; b=pPksHNOvxVQktD+GcAmcawkCYt9qVp5vG8s1gtFbOyz5o4CKPEdSeH5n dHeHBNCCqikkWjd6XXlqLBCiPBe8pDddFe3Pi0bLUib1MJFk0O3mjkZAA Ixmjwsfagq6R0aP902UB0TSQQ2bc8wHqLJtwr3sWDblFXOYMxB5wN0pM1 iy//o/C0eH6EazuB0Vs3wLbgHTPTPej3vP7ODasx0mmdwDKdnRPhKttRE ysbnBBbK4Rly8+QIK/sPPbr1H1inxUI0XvPIcNjCk629mmrCs/ij5cP85 7NZsH7SXE/E2TXOheHtnLKCQwPgd8tkEK3WpWG1Ivc4ThBH3iuduhGiGb g==; X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="168507967" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Jun 2022 04:33:04 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Jun 2022 04:33:04 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Jun 2022 04:33:02 -0700 From: Conor Dooley To: Mark Brown CC: Daire McNamara , Lewis Hanly , Conor Dooley , , , , Dan Carpenter Subject: [PATCH] spi: microchip-core: fix passing zero to PTR_ERR warning Date: Wed, 15 Jun 2022 12:30:22 +0100 Message-ID: <20220615113021.2493586-1-conor.dooley@microchip.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org It is possible that the error case for devm_clk_get() returns NULL, in which case zero will be passed to PTR_ERR() as shown by the Smatch static checker warning: drivers/spi/spi-microchip-core.c:557 mchp_corespi_probe() warn: passing zero to 'PTR_ERR' Fix the warning by explicitly returning an error if devm_clk_get() returns NULL. Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers") Reported-by: Dan Carpenter Link: https://lore.kernel.org/linux-spi/20220615091633.GI2168@kadam/ Signed-off-by: Conor Dooley --- drivers/spi/spi-microchip-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-microchip-core.c b/drivers/spi/spi-microchip-core.c index 5b2aee30fa04..d44663cca071 100644 --- a/drivers/spi/spi-microchip-core.c +++ b/drivers/spi/spi-microchip-core.c @@ -554,7 +554,7 @@ static int mchp_corespi_probe(struct platform_device *pdev) spi->clk = devm_clk_get(&pdev->dev, NULL); if (!spi->clk || IS_ERR(spi->clk)) { - ret = PTR_ERR(spi->clk); + ret = !spi->clk ? -ENXIO : PTR_ERR(spi->clk); dev_err(&pdev->dev, "could not get clk: %d\n", ret); goto error_release_master; }