Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1186452ybe; Mon, 2 Sep 2019 16:17:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg19G6nMiyrXKNB7Ard7i89eCK6QCqIZj4jJ9ZpgjDNavCRL3AEWD+iQB45s4Er3QvQzpy X-Received: by 2002:a63:2784:: with SMTP id n126mr26390109pgn.92.1567466235324; Mon, 02 Sep 2019 16:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567466235; cv=none; d=google.com; s=arc-20160816; b=isIWfmzO97OsIqphGAEIbcbko2qqmQ17PY09C5Fm3UvdWUxTULLglkMjQkfI7gRV9k lxtT6FBgtSxkj7Hi4OaZak9X7HiVqi+iLfyXru6xX4UBUs1QngPxSdHWw8xwjcKzke/n UOG2o0velFYGBlQh9WfeV3ab8RcVtO6IInZW4garpuLyXWMpA9gmL05EMTIb1A9oRU20 dFvrk+LXJW8Qy3bFo3I+Nusz8P0Gpq6ffatGjwZNSNZnDQEtUk2bdMt11j2xQCjvphxI xuli1UMqkO7nFmsmASTM/LvZsxXzz1144PHFNBw4tXCyr98VY1LRjdakGhtg8pSWBfMO uSvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :ironport-phdr:ironport-sdr:dkim-signature; bh=qbPcGIvjek55/mukFc57PQHYy7743OrNG7Y4v0Ab2d0=; b=tnElf2IdyHGfSjGoyxIMkqJW4TWEDNnfgd3Zv30zMj2u+1gODqb5DP8Yi1c70uoVPl h1qNIwwql2PrMxce6ro91vfUy4lP916nygfwDlBP/vN6MrCBTbgikxk3PBTc6eP3SMNm R76YN823Mhs62m+RPFBPQPwDjb5yERm9Xd2izSEp3hxv+l2+xoKISUZ2zKMvCAvL6TSS dtRV03xQyDCDEzTDJX/VTToYenWaDOeyyldlTKA0PW3jjmtb2f6fS2w6kxzicKxD8Yp1 FfORnGTNkVcs0I9ZIrceEv+HQWI8HvOwopT+eVDldQWf8gUpL09Ka2yGQVRxVzd064PR A6ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ucr.edu header.s=selector3 header.b=OhnTr0ld; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ucr.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si12896543pgu.16.2019.09.02.16.16.57; Mon, 02 Sep 2019 16:17:15 -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=fail header.i=@ucr.edu header.s=selector3 header.b=OhnTr0ld; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ucr.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726974AbfIBXOi (ORCPT + 99 others); Mon, 2 Sep 2019 19:14:38 -0400 Received: from mx1.ucr.edu ([138.23.248.2]:5684 "EHLO mx1.ucr.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfIBXOh (ORCPT ); Mon, 2 Sep 2019 19:14:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ucr.edu; i=@ucr.edu; q=dns/txt; s=selector3; t=1567466279; x=1599002279; h=from:to:cc:subject:date:message-id; bh=wrJn6aBHz0Uw1eGhnnd+uYHpG8nT9vsMJN2vUur/bWQ=; b=OhnTr0ldt5Mv8QIOqfKoGO5jKzVcBnhz2phCnjp8HMy3Z4zhSBlPlWZP EdYsMgKQVGFjDTBARnjzO1+p3Zcad2mYHadNlnF8b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UVixBGZi8b4oJD+oOIO1WsZDzrEYArRu/GwasAP7gwSJMinL4waE21u?= =?us-ascii?q?IsGhzE0gM9BdIDqHTaosvoOqkcUu67y7LFwSnfY/5MxTvw8pTEfgwnrPqRXb?= =?us-ascii?q?xwa83RyUw3GgzHj1WRqIzlPy6S1u8QtGWa7+thVeK1hG4mtw19vjaiy9wxio?= =?us-ascii?q?bVnIIZ0E7L+jhkwIssI9CzVU11Yca8HZdOqy2XM5F6T8AiTm1ypio216EKtY?= =?us-ascii?q?SmcCUOy5kr3wPTZv2DfoSS/B7uWuacLS1miH9kYr6yhRm//E69wePmTMa0yk?= =?us-ascii?q?xFri9dn9nJsXACygLc59CcSvt44kehwTGP1x3P6u1cIUA7i67bK5k5z741jJ?= =?us-ascii?q?UTsEDDEjbumEX4kaOab0sk9vWs5unkeLnmqZicN4h7igH6LKsigNCwAeM9Mg?= =?us-ascii?q?QWXmib//qz1KH78EHnXLlHiuc6n6rZvZzAO8gXu7K1DxVI3osn6BuzFzKm38?= =?us-ascii?q?4ZnXkDIlJFYhWHj43xNlDOIfH4De2wg1WwnDt3yf3LJaDhDYnXLnTZjrjuYK?= =?us-ascii?q?t951ZGyAUv1dBf+45UCrYZLfL3W0/xssHYDxAgPwy33ennEtN92Z0aWW+UHK?= =?us-ascii?q?+ZP73dsUWS6uIsPeaMfokVtyj5K/Q/4P7ul3A5yhczZ66siKoWenClGbwyMl?= =?us-ascii?q?eZaHu02owpDGwQ+AcyUbq52xW5TTdPaiPqDOoH7TYhBdfjUt/O?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2E8AACqgmddh8bSVdFlHgEGBwaBUwk?= =?us-ascii?q?LAYNXTBCNHYZdAQEGix8YcYV5gwmFJIF7AQgBAQEMAQEtAgEBhD+CWyM0CQ4?= =?us-ascii?q?CAwgBAQUBAQEBAQYEAQECEAEBAQgNCQgphUGCOimCYAsWFVJWPwEFATUiOYJ?= =?us-ascii?q?HAYF2FJ08gQM8jCMziGkBCAyBSQkBCIEiAYcdhFmBEIEHhGGEDYNWgkQEgS4?= =?us-ascii?q?BAQGUTpYFAQYCAYIMFIFyklMngjKBfokZOYpaAS2ldwIKBwYPIYEvghFNJYF?= =?us-ascii?q?sCoFEglweji0fM4EIjAGCVAE?= X-IPAS-Result: =?us-ascii?q?A2E8AACqgmddh8bSVdFlHgEGBwaBUwkLAYNXTBCNHYZdA?= =?us-ascii?q?QEGix8YcYV5gwmFJIF7AQgBAQEMAQEtAgEBhD+CWyM0CQ4CAwgBAQUBAQEBA?= =?us-ascii?q?QYEAQECEAEBAQgNCQgphUGCOimCYAsWFVJWPwEFATUiOYJHAYF2FJ08gQM8j?= =?us-ascii?q?CMziGkBCAyBSQkBCIEiAYcdhFmBEIEHhGGEDYNWgkQEgS4BAQGUTpYFAQYCA?= =?us-ascii?q?YIMFIFyklMngjKBfokZOYpaAS2ldwIKBwYPIYEvghFNJYFsCoFEglweji0fM?= =?us-ascii?q?4EIjAGCVAE?= X-IronPort-AV: E=Sophos;i="5.64,443,1559545200"; d="scan'208";a="5470477" Received: from mail-pf1-f198.google.com ([209.85.210.198]) by smtp1.ucr.edu with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2019 16:17:58 -0700 Received: by mail-pf1-f198.google.com with SMTP id z13so9609232pfr.15 for ; Mon, 02 Sep 2019 16:14:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qbPcGIvjek55/mukFc57PQHYy7743OrNG7Y4v0Ab2d0=; b=akB6V87MIelXqA69qufz3gN9sCMwdUL6nhU9fXTVasTV/neN4XsUBINreyiIdcggeh u4nAuKdQM5mIT/wed9aaXSHy2VvFtkkzSjdQ0UA1hBj+b8tjuOc8d0dSAMGaKDRoziM7 QjbwAOwoT3ExCZ8C1WugNdx8SxrQB/bc9xThG4Syrxzdow5xBecJuEgeIsPC4bDC9bh0 p7tK1ZrbRQN/QzDKjkiKLA0NbBVQkWV+qtzjLXCO9BK50/CPeG8d6y2smnRH4cjhau7m OLYUER2ifY4EkLQoAip09ppoT8N3LsR/FWeDeI95Qa1jOP4GNfjnTO+8fHBjFylut+zl z0eg== X-Gm-Message-State: APjAAAUNRhtWhCjqKJ+LYiwJM3d71VxQvD0akpvfvKolGnuJ/bVPDXBt ztBLMcHwLl3KrxxQniH+Ot67aamYK5sPDBHbpmXDcTB7TB0b43nlr+YLnxN5Tii/rrMyk28TcQf KKw3V1gf5FaYI+rqk3tZ2aYTyCA== X-Received: by 2002:a17:902:9f97:: with SMTP id g23mr25566848plq.248.1567466076389; Mon, 02 Sep 2019 16:14:36 -0700 (PDT) X-Received: by 2002:a17:902:9f97:: with SMTP id g23mr25566835plq.248.1567466076169; Mon, 02 Sep 2019 16:14:36 -0700 (PDT) Received: from Yizhuo.cs.ucr.edu (yizhuo.cs.ucr.edu. [169.235.26.74]) by smtp.googlemail.com with ESMTPSA id 138sm18270374pfw.78.2019.09.02.16.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2019 16:14:35 -0700 (PDT) From: Yizhuo Cc: csong@cs.ucr.edu, zhiyunq@cs.ucr.edu, Yizhuo , Yisen Zhuang , Salil Mehta , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: hisilicon: Variable "reg_value" in function mdio_sc_cfg_reg_write() could be uninitialized Date: Mon, 2 Sep 2019 16:15:10 -0700 Message-Id: <20190902231510.21374-1-yzhai003@ucr.edu> X-Mailer: git-send-email 2.17.1 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function mdio_sc_cfg_reg_write(), variable reg_value could be uninitialized if regmap_read() fails. However, this variable is used later in the if statement, which is potentially unsafe. Signed-off-by: Yizhuo --- drivers/net/ethernet/hisilicon/hns_mdio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c b/drivers/net/ethernet/hisilicon/hns_mdio.c index 3e863a71c513..f5b64cb2d0f6 100644 --- a/drivers/net/ethernet/hisilicon/hns_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns_mdio.c @@ -148,11 +148,17 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device *mdio_dev, { u32 time_cnt; u32 reg_value; + int ret; regmap_write(mdio_dev->subctrl_vbase, cfg_reg, set_val); for (time_cnt = MDIO_TIMEOUT; time_cnt; time_cnt--) { - regmap_read(mdio_dev->subctrl_vbase, st_reg, ®_value); + ret = regmap_read(mdio_dev->subctrl_vbase, st_reg, ®_value); + if (ret) { + dev_err(mdio_dev->regmap->dev, "Fail to read from the register\n"); + return ret; + } + reg_value &= st_msk; if ((!!check_st) == (!!reg_value)) break; -- 2.17.1