From patchwork Fri Oct 18 08:24:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Bin X-Patchwork-Id: 11197735 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 DBBE517E1 for ; Fri, 18 Oct 2019 08:17:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7940222C3 for ; Fri, 18 Oct 2019 08:17:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404256AbfJRIRc (ORCPT ); Fri, 18 Oct 2019 04:17:32 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4722 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2395313AbfJRIRb (ORCPT ); Fri, 18 Oct 2019 04:17:31 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9897D60E22E5ABECFCC9; Fri, 18 Oct 2019 16:17:29 +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:22 +0800 From: zhengbin To: , , , CC: , , Subject: [PATCH v5 04/13] scsi: sr: need to check the result of scsi_execute in sr_get_events Date: Fri, 18 Oct 2019 16:24:22 +0800 Message-ID: <1571387071-28853-5-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 the result of scsi_execute. Signed-off-by: zhengbin --- drivers/scsi/sr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 4664fdf..5c5476b 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -205,7 +205,8 @@ static unsigned int sr_get_events(struct scsi_device *sdev) result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, sizeof(buf), &sshdr, SR_TIMEOUT, MAX_RETRIES, NULL); - if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION) + if (driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr) && + sshdr.sense_key == UNIT_ATTENTION) return DISK_EVENT_MEDIA_CHANGE; if (result || be16_to_cpu(eh->data_len) < sizeof(*med))