From patchwork Thu May 23 01:38:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10956825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F8A86C5 for ; Thu, 23 May 2019 01:39:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 027F92793A for ; Thu, 23 May 2019 01:39:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA34427B13; Thu, 23 May 2019 01:39:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95AEA2793A for ; Thu, 23 May 2019 01:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728050AbfEWBjZ (ORCPT ); Wed, 22 May 2019 21:39:25 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:42727 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727691AbfEWBjY (ORCPT ); Wed, 22 May 2019 21:39:24 -0400 Received: by mail-ed1-f68.google.com with SMTP id l25so6616368eda.9; Wed, 22 May 2019 18:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NKATGLeNnniTBFpU50i8agrrLlqQcy95+OH3gC4PMT8=; b=u+MViJB9B2kgG2a4MaeIpZL8gjHhUl3RRaTjXuleISXPUcVyDs3nCGV2mrkUU0Gfli qPYh1LjGdRzRwfbeqGoBKFGcQtYAVC6NtwqsaIKwqRyKWSE/kQMp2JS38KM4rLrNCm81 ABu9HRv1b0m+D/4QZEovMWQlVwhw20GIKTmCZ1dGLSYcggRXVQQEM4YUjEvdYx42HGXg C16zi8KgabNgzFjbl3h+6ajnbz/pvoD3scaZEXC/tNjYQEhS8+eF1aFMWaUmu+1FHctu MgT5xxVDVlOANgkBuz+3lf0oVOIk/ZneZ1emQyJhCgJtUKRP1iIBtKszftz6YiCUdMeG 9ZXQ== 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:mime-version :content-transfer-encoding; bh=NKATGLeNnniTBFpU50i8agrrLlqQcy95+OH3gC4PMT8=; b=CCMXREslL2uONO32eKv1zZ/khnB/HARNj2bJ3C8DrQ3loyW+pRTmJk22czTVuuF2Tn 9/b0EdjLBFeBbiusDb2PTaiRdjDhwj30927rDg1wHsok5RZ2p6blp7mh8vDBBah9big8 4lJAtbM7drA2SN5Mr1pADtuMo8L5QAHAbJ+V73TZvdZT5uCHVaF17xpaqtkcG7zPHIkG 8WE7rO7REKgQB/9FXXPD88VHFUjCMRq7RKLUxSV3rOOVqqik8sTwHje7z4aPQpKNFhS8 5PVEDLZn6gEhHflGqbp3xsZZ+aBJrB5p9Ic8LE10xvXQxf2alhWHZ+zw7kavWYEaxRjb IDCw== X-Gm-Message-State: APjAAAWSuok92QiX9iqGPEM4gIpaqxK3hlUFZkjeTvvfd45mgIx1licd wY/NdagCZZauPrt3+nNLv9A= X-Google-Smtp-Source: APXvYqzFHrp2yRn2Vtm3VTNZBtFzuYr2Gy7RFeF6eg84Z8+woNf2GoaXkYvzJTM1q8Zzou7UWB4yfw== X-Received: by 2002:a50:ce06:: with SMTP id y6mr93652104edi.160.1558575562868; Wed, 22 May 2019 18:39:22 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:2b:2b15::2]) by smtp.gmail.com with ESMTPSA id w5sm7725340edd.19.2019.05.22.18.39.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 18:39:21 -0700 (PDT) From: Nathan Chancellor To: Don Brace Cc: "James E.J. Bottomley" , "Martin K. Petersen" , esc.storagedev@microsemi.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers , clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH] scsi: hpsa: Avoid using dev uninitialized in hpsa_eh_device_reset_handler Date: Wed, 22 May 2019 18:38:59 -0700 Message-Id: <20190523013859.14778-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.22.0.rc1 MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clang warns: drivers/scsi/hpsa.c:5964:6: warning: variable 'dev' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (lockup_detected(h)) { ^~~~~~~~~~~~~~~~~~ drivers/scsi/hpsa.c:6042:6: note: uninitialized use occurs here if (dev) ^~~ drivers/scsi/hpsa.c:5964:2: note: remove the 'if' if its condition is always false if (lockup_detected(h)) { ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/scsi/hpsa.c:5950:29: note: initialize the variable 'dev' to silence this warning struct hpsa_scsi_dev_t *dev; ^ = NULL 1 warning generated. dev is potentially used uninitialized in the return_reset_status block for a NULL check if the first 'if (lockup_detected(h))' is taken, as dev is initialized right after that block. Initialize dev to NULL in its declaration so that it can be safely checked within the return_reset_status block. Fixes: 14991a5bade5 ("scsi: hpsa: correct device resets") Link: https://github.com/ClangBuiltLinux/linux/issues/492 Signed-off-by: Nathan Chancellor --- drivers/scsi/hpsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index c560a4532733..ac8338b0571b 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -5947,7 +5947,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) int rc = SUCCESS; int i; struct ctlr_info *h; - struct hpsa_scsi_dev_t *dev; + struct hpsa_scsi_dev_t *dev = NULL; u8 reset_type; char msg[48]; unsigned long flags;