From patchwork Tue Dec 12 08:57:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10106513 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 9567F6032B for ; Tue, 12 Dec 2017 08:58:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 891E529B36 for ; Tue, 12 Dec 2017 08:58:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E00729B3B; Tue, 12 Dec 2017 08:58:02 +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=-6.9 required=2.0 tests=BAYES_00,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 4148D29B36 for ; Tue, 12 Dec 2017 08:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752259AbdLLI6B (ORCPT ); Tue, 12 Dec 2017 03:58:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:46994 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752258AbdLLI55 (ORCPT ); Tue, 12 Dec 2017 03:57:57 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B71F9AEC1; Tue, 12 Dec 2017 08:57:55 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Bart van Assche , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 2/4] sd: Check if parent is still present before proceeding with probing Date: Tue, 12 Dec 2017 09:57:50 +0100 Message-Id: <1513069072-32514-3-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1513069072-32514-1-git-send-email-hare@suse.de> References: <1513069072-32514-1-git-send-email-hare@suse.de> 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 When a new SCSI disk is created we should be checking if the parent device is actually present before proceeding with probing. Signed-off-by: Hannes Reinecke --- drivers/scsi/sd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ab75ebd..228b0b62 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3399,6 +3399,10 @@ static int sd_probe(struct device *dev) } device_initialize(&sdkp->dev); + + if (!get_device(dev)) + goto out_free_index; + sdkp->dev.parent = dev; sdkp->dev.class = &sd_disk_class; dev_set_name(&sdkp->dev, "%s", dev_name(dev)); @@ -3407,7 +3411,6 @@ static int sd_probe(struct device *dev) if (error) goto out_free_index; - get_device(dev); dev_set_drvdata(dev, sdkp); get_device(&sdkp->dev); /* prevent release before async_schedule */