From patchwork Thu May 31 08:42:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10440543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F83E602BD for ; Thu, 31 May 2018 08:42:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D59028E97 for ; Thu, 31 May 2018 08:42:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5199728EA9; Thu, 31 May 2018 08:42:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D511828E97 for ; Thu, 31 May 2018 08:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754049AbeEaIms (ORCPT ); Thu, 31 May 2018 04:42:48 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:35643 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754023AbeEaImp (ORCPT ); Thu, 31 May 2018 04:42:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1527756316; x=1559292316; h=from:to:cc:subject:date:message-id; bh=IBqbaANcLpQGdI9HWb+U0UmSLe3maxXi8rGaxHr1y8Q=; b=L2se840KGljnQH4tnAObVIYlNw3NNrP2AaIBWeyghZ2kKyqhI9JbMZ23 b638uANn4vChCb8PZU/iaD43GwPUxpJlMIxGHA2AnR4AKbswvB0ZZvTPA IfiPZMLSAMUxS+tzVyqnavspXTfyTWPbHdcU8MRnQhcWrzBQAG+rVZxNj qs58HZRyl35Xh3U7B2Npiic+VpZCiim/D+LrAZBT4ZlX07G0ApVL2mSxl CDRGaRl/CkyaP9zt44QFnNS/VNDy96DVRxmo2VaUp8DHR2DUg9Maceu7s AjQ9+ISOdbzoxQOsjnhNunzW9Np3DM/thdn1evwrsixpMDkXvT6Iy1Z1t Q==; X-IronPort-AV: E=Sophos;i="5.49,463,1520870400"; d="scan'208";a="176171203" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 31 May 2018 16:45:16 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 31 May 2018 01:32:55 -0700 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 31 May 2018 01:42:45 -0700 From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: Bart Van Assche , Hannes Reinecke , Bart Van Assche Subject: [PATCH] sd_zbc: Fix sd_zbc_check_zone_size() error path Date: Thu, 31 May 2018 17:42:40 +0900 Message-Id: <20180531084240.11104-1-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.17.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a drive with variable zone sizes or an invalid last zone size is detected, the local variable this_zone_blocks is set to 0 and early retrun from the function triggered, but this does not result in an error return. The local variable zone_blocks must be set to 0 for an error to be returned. Fixes: ccce20fc7968 ("scsi: sd_zbc: Avoid that resetting a zone fails sporadically") Signed-off-by: Damien Le Moal Cc: Bart Van Assche Reviewed-by: Bart Van Assche --- drivers/scsi/sd_zbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 323e3dc4bc59..850c803a6b3d 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -442,7 +442,7 @@ static s64 sd_zbc_check_zone_size(struct scsi_disk *sdkp) } else if (this_zone_blocks != zone_blocks && (block + this_zone_blocks < sdkp->capacity || this_zone_blocks > zone_blocks)) { - this_zone_blocks = 0; + zone_blocks = 0; goto out; } block += this_zone_blocks;