From patchwork Fri Oct 18 08:24:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Bin X-Patchwork-Id: 11197759 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 D6EBA69B1 for ; Fri, 18 Oct 2019 08:17:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C27A821D7C for ; Fri, 18 Oct 2019 08:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504793AbfJRIRk (ORCPT ); Fri, 18 Oct 2019 04:17:40 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4686 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2442192AbfJRIRh (ORCPT ); Fri, 18 Oct 2019 04:17:37 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C7F95E95AFB6B0DBA3E2; 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:25 +0800 From: zhengbin To: , , , CC: , , Subject: [PATCH v5 13/13] scsi: ch: need to check whether sshdr is valid in ch_do_scsi Date: Fri, 18 Oct 2019 16:24:31 +0800 Message-ID: <1571387071-28853-14-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/ch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 76751d6..dba6fe2 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -200,7 +200,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, buflength, &sshdr, timeout * HZ, MAX_RETRIES, NULL); - if (driver_byte(result) == DRIVER_SENSE) { + if (driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr)) { if (debug) scsi_print_sense_hdr(ch->device, ch->name, &sshdr); errno = ch_find_errno(&sshdr); @@ -212,7 +212,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, goto retry; break; } - } + } else if (result) + errno = -EIO; + return errno; }