From patchwork Wed Jun 2 13:30:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 453747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38074C47083 for ; Wed, 2 Jun 2021 13:31:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20E50613D6 for ; Wed, 2 Jun 2021 13:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbhFBNcx (ORCPT ); Wed, 2 Jun 2021 09:32:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45536 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbhFBNcv (ORCPT ); Wed, 2 Jun 2021 09:32:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622640667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wsl3NWN7p0+Kd/t2d7QPZD5qkLCKK1el/ss3zxa6cCc=; b=E8VF2Sh7CcfLSQSD+DURmyqYRAQu8d2TusxeT9c1A3MgJNc8cbdbDnhfjzFD0MyfZb65IL vGx4XCgsKiQd9dNRBLsggMSpyauDAjCJqzLMkere+t57E+L2xa7gmKvsTRZZezdN/rOvUK VtqfUXrZt2+HbB/xpWyd3IetWx/xOGM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-Z1tZTHKcNX-6R1vESRQIRw-1; Wed, 02 Jun 2021 09:31:04 -0400 X-MC-Unique: Z1tZTHKcNX-6R1vESRQIRw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B833801B16; Wed, 2 Jun 2021 13:31:03 +0000 (UTC) Received: from localhost (ovpn-12-176.pek2.redhat.com [10.72.12.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FAA119D9B; Wed, 2 Jun 2021 13:30:58 +0000 (UTC) From: Ming Lei To: "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Ming Lei , Bart Van Assche , John Garry , Hannes Reinecke Subject: [PATCH 4/4] scsi: core: only put parent device if host state isn't in SHOST_CREATED Date: Wed, 2 Jun 2021 21:30:29 +0800 Message-Id: <20210602133029.2864069-5-ming.lei@redhat.com> In-Reply-To: <20210602133029.2864069-1-ming.lei@redhat.com> References: <20210602133029.2864069-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org get_device(shost->shost_gendev.parent) is called after host state is changed to SHOST_RUNNING. So scsi_host_dev_release() shouldn't release the parent device if host state is still SHOST_CREATED. Cc: Bart Van Assche Cc: John Garry Cc: Hannes Reinecke Signed-off-by: Ming Lei Reviewed-by: John Garry --- drivers/scsi/hosts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 7049844adb6b..34db5be7a562 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -350,7 +350,7 @@ static void scsi_host_dev_release(struct device *dev) ida_simple_remove(&host_index_ida, shost->host_no); - if (parent) + if (shost->shost_state != SHOST_CREATED) put_device(parent); kfree(shost); }