From patchwork Wed Apr 17 07:40:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pan Bian X-Patchwork-Id: 10904807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AD7F13B5 for ; Wed, 17 Apr 2019 07:56:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A35F28A19 for ; Wed, 17 Apr 2019 07:56:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DF2228A27; Wed, 17 Apr 2019 07:56:22 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 AB32728A19 for ; Wed, 17 Apr 2019 07:56:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731517AbfDQH4P (ORCPT ); Wed, 17 Apr 2019 03:56:15 -0400 Received: from proxy22674.mail.163.com ([113.108.226.74]:47252 "EHLO proxy22674.mail.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729328AbfDQH4O (ORCPT ); Wed, 17 Apr 2019 03:56:14 -0400 X-Greylist: delayed 907 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 Apr 2019 03:56:13 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=EJs+Pn75tQ8zEK66nG hKJeT69tU9ljVkzK9qJi3DK2M=; b=p9Jf6mR4GutUpUfvZC6M4w/RMVT9KPaQ1m UcujxjgBm7hO5LUtDDJFmKPtYQrfH8gjV3JQFlsesZQAXvgjJNtkQYRgShvQUKmY 2EjOBsmGFQ6+uZkSDJ02PDCgUmX+1eKxJnZRwXFYQtEKNgNVYpni+bMBCyV+Von8 kOmUlIO4o= Received: from bp.localdomain (unknown [218.106.182.174]) by smtp3 (Coremail) with SMTP id DdGowADn99dY2LZcr4YVAA--.35S3; Wed, 17 Apr 2019 15:40:11 +0800 (CST) From: Pan Bian To: Willem Riede , "James E.J. Bottomley" , "Martin K. Petersen" Cc: osst-users@lists.sourceforge.net, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: scsi: osst: drop SCSI devie reference taken before Date: Wed, 17 Apr 2019 15:40:00 +0800 Message-Id: <1555486800-107606-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: DdGowADn99dY2LZcr4YVAA--.35S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrurWDJry3Gr4rGFy5Gry5XFb_yoWfXFcE9r Z2qw1xWr9Ygr4kXFyak3y3Zr929a1DXa4fur4Sqw1rCrWSvFnxG34rXr9xZrs7C3yxG34j 93WkZr1avr1UGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbZqXtUUUUU== X-Originating-IP: [218.106.182.174] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiNguZclWBeIps0wAAsP 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 In the function __os_scsi_tape_open, scsi_device_get is called to take a reference of the device. The reference should be dropped when it is no longer used. However, when scsi_block_when_processing_errors returns a false value, the reference is not dropped. This patch fixes the bug. Signed-off-by: Pan Bian --- drivers/scsi/osst.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index be3c73e..f2b2b86 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -4489,7 +4489,8 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp) STp->rew_at_close = TAPE_REWIND(inode); if( !scsi_block_when_processing_errors(STp->device) ) { - return -ENXIO; + retval = -ENXIO; + goto err_out; } if (mode != STp->current_mode) {