From patchwork Fri Oct 18 08:24:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Bin X-Patchwork-Id: 11197753 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72ADA69B7 for ; Fri, 18 Oct 2019 08:17:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E2B221925 for ; Fri, 18 Oct 2019 08:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2442194AbfJRIRh (ORCPT ); Fri, 18 Oct 2019 04:17:37 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4682 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2442196AbfJRIRh (ORCPT ); Fri, 18 Oct 2019 04:17:37 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 991DF778835C0B7F7411; Fri, 18 Oct 2019 16:17:34 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Fri, 18 Oct 2019 16:17:24 +0800 From: zhengbin To: , , , CC: , , Subject: [PATCH v5 11/13] scsi: cxlflash: need to check whether sshdr is valid in read_cap16 Date: Fri, 18 Oct 2019 16:24:29 +0800 Message-ID: <1571387071-28853-12-git-send-email-zhengbin13@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571387071-28853-1-git-send-email-zhengbin13@huawei.com> References: <1571387071-28853-1-git-send-email-zhengbin13@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Like sd_pr_command, before use sshdr, we need to check whether sshdr is valid. Signed-off-by: zhengbin --- drivers/scsi/cxlflash/superpipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index 593669a..1e90ff3 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -369,7 +369,7 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli) goto out; } - if (driver_byte(result) == DRIVER_SENSE) { + if (driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr)) { result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ if (result & SAM_STAT_CHECK_CONDITION) { switch (sshdr.sense_key) {