Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2251030ybg; Sun, 27 Oct 2019 14:24:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXPKaEzY0ANY1gz9hBWS6EkUgzI1PSCihuXjWXEtATwZjI0HuBC9pBfP+DRlDRwuTALpXj X-Received: by 2002:a17:906:2989:: with SMTP id x9mr13701214eje.318.1572211445196; Sun, 27 Oct 2019 14:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572211445; cv=none; d=google.com; s=arc-20160816; b=WMA8wsKA1EX8N5u0CYd4JOVOdndTqESAif3QYb0rpAhiYCkLCoqgvxqokRncAz/6vx DSIeC8rHy79Kk2NoEyB3fRlSx4qWKr40dv0Ig2/+6aXxRGDID6pn7tl5VW8fg10FqsGS PAsqQhAST4cj8kbl+I7gelxdxmJAnuUvOTsF3LsfrcusmQiWMAz3I+Q9WH+lYTasPQ6U /dKXYZzSPZKzueCxz1WHMG+Ea8I9pX2vuDJxAXkzZ134CnZY6ecuEv+8e7CCmehDAX2X I/nLbCjzQHa0Ugoa3MBBpCtIYeJ12FoyAUMfukz19SdP29hdPkayP1J+G5E/FNKZUizj L/HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gKQ1dnCTwVMBUt9a2+uM5w7wt0DjofJYofxotFW3QYU=; b=hnXOBW70xEP+QmSTt0DF+QHo7b9MxeBWeN/Q3tbnm16AIQU430vI4SRBzCfL8GzbAZ 5VeGZ6GW0gWXON6yX+hNrGNgA1Y5Auxv+ITioUEun3OzTnwUvyDP5/my348AgzMJpt/r ksQ8YHZOWTN4r0cJa25FxwE0HisSukeHySFb4dzjXLntBwzS9yH+NLqq6DyeB5+2sMv+ 31KCVJD3wVuBVVmuomREABmueW7uFcQxoTqDYZZjlyE8iZSCttJhR8gmvW74dRjy2gkt Kll7yTUpJgeewa15X6sNon1lTeNevKbk29/DM1CMqTLPaGUX6xfV+gBsvGss3TbfNMX6 0oWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dDLrfVOd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13si4883593ejt.319.2019.10.27.14.23.41; Sun, 27 Oct 2019 14:24:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dDLrfVOd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732098AbfJ0VWN (ORCPT + 99 others); Sun, 27 Oct 2019 17:22:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:43148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732084AbfJ0VWK (ORCPT ); Sun, 27 Oct 2019 17:22:10 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05A722070B; Sun, 27 Oct 2019 21:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211329; bh=qSmlTE+QgmSY9E9tC6knfwegASSxSRMMw6TO5CL9/D8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dDLrfVOdUXHauLiQ4cvnPQY9sIkE1W4kmWxWLwxobS2k/UrLrTJwsSXVAvtTQU3Br u1oRefYbt4VeOTpXRL3F9Bc68sRqTB1xA+y2palmlw1Y5/PcRORAxQKoG3nnd+lM2e i0tRhKA66JXCaYkRZokFb/ZIUza/yuRlApgAXEow= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hannes Reinecke , Rob Turk , Bart Van Assche , "Martin K. Petersen" Subject: [PATCH 5.3 113/197] scsi: ch: Make it possible to open a ch device multiple times again Date: Sun, 27 Oct 2019 22:00:31 +0100 Message-Id: <20191027203357.843173402@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203351.684916567@linuxfoundation.org> References: <20191027203351.684916567@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bart Van Assche commit 6a0990eaa768dfb7064f06777743acc6d392084b upstream. Clearing ch->device in ch_release() is wrong because that pointer must remain valid until ch_remove() is called. This patch fixes the following crash the second time a ch device is opened: BUG: kernel NULL pointer dereference, address: 0000000000000790 RIP: 0010:scsi_device_get+0x5/0x60 Call Trace: ch_open+0x4c/0xa0 [ch] chrdev_open+0xa2/0x1c0 do_dentry_open+0x13a/0x380 path_openat+0x591/0x1470 do_filp_open+0x91/0x100 do_sys_open+0x184/0x220 do_syscall_64+0x5f/0x1a0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: 085e56766f74 ("scsi: ch: add refcounting") Cc: Hannes Reinecke Cc: Link: https://lore.kernel.org/r/20191009173536.247889-1-bvanassche@acm.org Reported-by: Rob Turk Suggested-by: Rob Turk Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ch.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -579,7 +579,6 @@ ch_release(struct inode *inode, struct f scsi_changer *ch = file->private_data; scsi_device_put(ch->device); - ch->device = NULL; file->private_data = NULL; kref_put(&ch->ref, ch_destroy); return 0;