From patchwork Mon Sep 24 15:06:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 147369 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp837467lji; Mon, 24 Sep 2018 08:10:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV62krK9pnke1hbeR40fhH8WBbFX5PMKMqqC67OItpOK75ULCqtxXs3LgztFmGWxrkuLiaOEK X-Received: by 2002:a63:754a:: with SMTP id f10-v6mr5410859pgn.137.1537801834059; Mon, 24 Sep 2018 08:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537801834; cv=none; d=google.com; s=arc-20160816; b=F5OG9GvoQPjA5BJz40fVjV8vP2+N7qS1Xg8EtP8nlrRt/ngsrIdmxiqW+XZVFJUnv1 FrL1HYtYSF/AQqG/WzZOHzZZQW8CITDHtUIGRH+k7t2jPnSBwJBjIE1q9JvPkHVORAoG V5J1/7tV7MlwSjNxnwj+UL9rI/IoA+nKu39oimTNmCGmZwMKSDTD8hetfVEaII7dqjpZ N4DWJPaHP4ZiVYifjpEKY5NN8CSOjpEhCXMKytzbNURHAX+fPYmdatrg6xpuuxcn4mXu aAXs+vD2llhptC1dNvjwIULSRPlqecKcgQxJ93/WRiWkwlCW/jCE1GRdjbocDz0zxkqO I/fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=rDND0EYXc3506dmUd7e4GcfD1mJJKzY5uvi74BffhZY=; b=RXo4Q5ohf4LMM8+FPYCO5PLhXBWXuBGtYrz+eo1+Etl3gsO47gqJPXn6wBbHHEwFtg 5iWkNC+2dY2C3XfCeXq3MP4PaFUgsrr5T5/9Dv0PZDv3X4DQ4NCUEqyDBQWZELG4xLug izabAnT0VwNQDEvu4MgAbegiq3KVgoqNEuhDr9azVNZaXiacMD2stG+oUNLXu+DRGoQ1 EaytsmlmsboaV/CGplIVUiKqku2HLrDa8QXoON2Ub1NeTAp2C5u3J6PDSiM+U3isoHLJ ltZYiNPKx4egNLOi6nNAvVUl+ZSAgar5wwbCv2KqLwUEDlRDMdI+z+Jre9bIO7tMCYVT QZgw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si14444588pgg.421.2018.09.24.08.10.33; Mon, 24 Sep 2018 08:10:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732251AbeIXVNI (ORCPT + 32 others); Mon, 24 Sep 2018 17:13:08 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:40826 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729844AbeIXVMU (ORCPT ); Mon, 24 Sep 2018 17:12:20 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 30373646D9320; Mon, 24 Sep 2018 23:09:40 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Mon, 24 Sep 2018 23:09:31 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 2/7] scsi: hisi_sas: Move evaluation of hisi_hba in hisi_sas_task_prep() Date: Mon, 24 Sep 2018 23:06:29 +0800 Message-ID: <1537801594-207139-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537801594-207139-1-git-send-email-john.garry@huawei.com> References: <1537801594-207139-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing In evaluating hisi_hba, the sas_port may be NULL, so for safety relocate the the check to value possible NULL deference. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index ba6fb535..3b95a7a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -287,13 +287,13 @@ static int hisi_sas_task_prep(struct sas_task *task, int *pass) { struct domain_device *device = task->dev; - struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); + struct hisi_hba *hisi_hba; struct hisi_sas_device *sas_dev = device->lldd_dev; struct hisi_sas_port *port; struct hisi_sas_slot *slot; struct hisi_sas_cmd_hdr *cmd_hdr_base; struct asd_sas_port *sas_port = device->port; - struct device *dev = hisi_hba->dev; + struct device *dev; int dlvry_queue_slot, dlvry_queue, rc, slot_idx; int n_elem = 0, n_elem_req = 0, n_elem_resp = 0; struct hisi_sas_dq *dq; @@ -314,6 +314,9 @@ static int hisi_sas_task_prep(struct sas_task *task, return -ECOMM; } + hisi_hba = dev_to_hisi_hba(device); + dev = hisi_hba->dev; + if (DEV_IS_GONE(sas_dev)) { if (sas_dev) dev_info(dev, "task prep: device %d not ready\n",