From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87993C352A3 for ; Tue, 11 Feb 2020 16:21:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63C582082F for ; Tue, 11 Feb 2020 16:21:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730055AbgBKQVE (ORCPT ); Tue, 11 Feb 2020 11:21:04 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:51982 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729823AbgBKQVD (ORCPT ); Tue, 11 Feb 2020 11:21:03 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1j1YHT-0007Ai-Tl; Tue, 11 Feb 2020 16:21:00 +0000 From: Colin King To: =?UTF-8?q?Nuno=20S=C3=A1?= , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] hwmon: axi-fan-control: fix uninitialized dereference of pointer res Date: Tue, 11 Feb 2020 16:20:59 +0000 Message-Id: <20200211162059.94233-1-colin.king@canonical.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Colin Ian King Currently the resource pointer ret is uninitialized and it is being dereferenced when printing out a debug message. Fix this by fetching the resource and assigning pointer res. It is a moot point that we sanity check for a null res since a successful call to devm_platform_ioremap_resource has already occurred so in theory it should never be non-null. Addresses-Coverity: ("Uninitialized pointer read") Fixes: 690dd9ce04f6 ("hwmon: Support ADI Fan Control IP") Signed-off-by: Colin Ian King --- drivers/hwmon/axi-fan-control.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hwmon/axi-fan-control.c b/drivers/hwmon/axi-fan-control.c index 8041ba7cc152..36e0d060510a 100644 --- a/drivers/hwmon/axi-fan-control.c +++ b/drivers/hwmon/axi-fan-control.c @@ -415,6 +415,9 @@ static int axi_fan_control_probe(struct platform_device *pdev) if (!ctl->clk_rate) return -EINVAL; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; dev_dbg(&pdev->dev, "Re-mapped from 0x%08llX to %p\n", (unsigned long long)res->start, ctl->base); -- 2.25.0