From patchwork Thu Jul 1 06:51:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1499369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GFpns0xb6z9sX5; Thu, 1 Jul 2021 16:53:21 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lyqZX-0002tf-JD; Thu, 01 Jul 2021 06:53:15 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lyqYR-0001so-R5 for kernel-team@lists.ubuntu.com; Thu, 01 Jul 2021 06:52:08 +0000 Received: from mail-ed1-f71.google.com ([209.85.208.71]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lyqYP-0007Nf-Ul for kernel-team@lists.ubuntu.com; Thu, 01 Jul 2021 06:52:05 +0000 Received: by mail-ed1-f71.google.com with SMTP id z5-20020a05640235c5b0290393974bcf7eso2519279edc.2 for ; Wed, 30 Jun 2021 23:52:05 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2g5UOzmf5hrTfZTsq5HBA0Qgrkryc8mmH3hm7nGHjMQ=; b=XbEiYYQt21JHU16RxRIL7k95b8gyBR/o3AVgheeNR0rppsCA+yJDl8TcekBuyQ3LyD I3O5Tri4vrXfmxn0EF1sa7eQI3Bi3rjZPLKVk1DETcGyfmnjmXhjD5VQK+xhVyApV/cN 3q/1zyNUQbiR77QEaLwzkB+RoSHc1DEaHRdps2jZIA8B5FS4EAJv8LeNBqWJNvUriIOu 5qyX32YkcPinDK1VN9Jl7Nzk7GthU9CYt71ZZrjcyaFz72i7bjAzQpAnI8Kibvnnl9lc qVO3024AGS1UHAv3ojYlj4huNSwszL968JYVFDQ1Psd/5v34XjolH2UsLtFtyF+g4eiC drow== X-Gm-Message-State: AOAM5305XEASOSBtck6EcTzUI/CVwsr0+geQjULEFjrW2iiZG3Ijkn/F GOb4pjkK2ospbaG1SkcNHBKz2NVL9VKOv7YBFZ2o55+hfDccxb4F3ghG2I5oGgjP0VHzxpNwrFK KvYVxO8HKNIV8dVNtspW8rj7B1++IV9hclN5+1T9Y9A== X-Received: by 2002:a05:6402:154:: with SMTP id s20mr52235497edu.103.1625122325289; Wed, 30 Jun 2021 23:52:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEkK89OgVjVQrWxlv4yHE8wS+0Um6Logs28zy/1WmpqAhHm8Navc/wyKjCzKBo9JSX9Z7Yjg== X-Received: by 2002:a05:6402:154:: with SMTP id s20mr52235479edu.103.1625122325124; Wed, 30 Jun 2021 23:52:05 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id t15sm10394144ejf.119.2021.06.30.23.52.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 23:52:04 -0700 (PDT) From: Krzysztof Kozlowski To: kernel-team@lists.ubuntu.com Subject: [PATCH][SRU][F-hwe-5.11 29/30] scsi: smartpqi: Fix device pointer variable reference static checker issue Date: Thu, 1 Jul 2021 08:51:40 +0200 Message-Id: <20210701065141.6018-30-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210701065141.6018-1-krzysztof.kozlowski@canonical.com> References: <20210701065141.6018-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Don Brace BugLink: https://bugs.launchpad.net/bugs/1933518 Dan Carpenter found a possible NULL pointer dereference issue in function pqi_sas_port_add_rphy(): drivers/scsi/smartpqi/smartpqi_sas_transport.c:97 pqi_sas_port_add_rphy() warn: variable dereferenced before check 'pqi_sas_port->device' (see line 95) Correct issue by moving reference of pqi_sas_port->device after the check for the device pointer being non-NULL. Link: https://www.mail-archive.com/kbuild@lists.01.org/msg06329.html Link: https://lore.kernel.org/r/161850493026.7302.10032784239320437353.stgit@brunhilda Fixes: ec504b23df9d ("scsi: smartpqi: Add phy ID support for the physical drives") Reported-by: Dan Carpenter Reported-by: kernel test robot Reviewed-by: Scott Benesh Reviewed-by: Scott Teel Reviewed-by: Mike McGowen Reviewed-by: Kevin Barnett Signed-off-by: Don Brace Signed-off-by: Martin K. Petersen (cherry picked from commit 5cad5a507241b4b72b7cad27cf769ac645e53d45) Signed-off-by: Krzysztof Kozlowski --- drivers/scsi/smartpqi/smartpqi_sas_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/smartpqi/smartpqi_sas_transport.c b/drivers/scsi/smartpqi/smartpqi_sas_transport.c index dd9b784792ef..dd628cc87f78 100644 --- a/drivers/scsi/smartpqi/smartpqi_sas_transport.c +++ b/drivers/scsi/smartpqi/smartpqi_sas_transport.c @@ -92,12 +92,12 @@ static int pqi_sas_port_add_rphy(struct pqi_sas_port *pqi_sas_port, identify = &rphy->identify; identify->sas_address = pqi_sas_port->sas_address; - identify->phy_identifier = pqi_sas_port->device->phy_id; identify->initiator_port_protocols = SAS_PROTOCOL_ALL; identify->target_port_protocols = SAS_PROTOCOL_STP; if (pqi_sas_port->device) { + identify->phy_identifier = pqi_sas_port->device->phy_id; switch (pqi_sas_port->device->device_type) { case SA_DEVICE_TYPE_SAS: case SA_DEVICE_TYPE_SES: