Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2265080pxb; Fri, 8 Oct 2021 04:31:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE8Yxacr9iWdRn5Ia/FX1g9aJQd/bJsN9VdZoTGuCWh47QCgc/MkZ0fDsRMF0A3ZtdIaav X-Received: by 2002:a17:902:e544:b0:13e:e863:6cd2 with SMTP id n4-20020a170902e54400b0013ee8636cd2mr8829740plf.41.1633692666935; Fri, 08 Oct 2021 04:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633692666; cv=none; d=google.com; s=arc-20160816; b=eRhjQKcqVr098ojaOxGWc0SHzdqQEkbHUAmlmToZawAvXz12Hz/RVQoG8x6DY0bfgu lY5gTyuenlsjpV7FxliTPQpAQL/wjan97ymfjVZNindG5FefVU46ILbIAAaumIRXDOGA LnN/V00Jh3LTsG7jmlgAgEVg9mcFo3kACm1s2vJVazq+n3w7GKbom7ngNy0ngWXGIGR4 jyzQWNiPPGwVRQTCQzITrW0TLHPDR4m07lHOXKed00IgyA50A1LxgXFim2NkS3ADQDQ7 FfKBwDY5zyLQKCzk2kIVqU1/ay6Zm8YOFvaat22tPvBlCAlAMJJYuFWoGj22w9b33OoW o9rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G9JzjB9wf8DHBNWLYIS8TPXC3MHffdf45WqM1D4LwS8=; b=uXkx3XqJUJZKgsPg1KmrzDNDhLJ8SasNO9LfPUGAq+w0UT5y/nvby0WqHegD2o1hHi EDjdIDgJ4/0dyBpYvyHGaJwRPbzu3Jbmzdf0bCjIETf5h3mvkUMfHYYbv0s5h/vrMy2V uXR7ilxlw9WVeO5dPvMiRQk3+E2MzH0VnwI5lnlGBftIF32rPzWHSuq+haxLlKdtGhL8 Hl4VR6ge5ulBXWLdQu95yGOatMn/Onl3+3iMLorZR6g0TcT8/eIbzglXyG5mlU1mokeQ RtGKEtnpzikYqxYrvXqkoHLLGwyRKsVAaEJyjLb3KVhiLRt4g4wYrR1645ZFdgbXt1zE 3GLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JnCeS8Tc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si20352175pfh.148.2021.10.08.04.30.53; Fri, 08 Oct 2021 04:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JnCeS8Tc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241002AbhJHLbm (ORCPT + 99 others); Fri, 8 Oct 2021 07:31:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:58592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240509AbhJHLbA (ORCPT ); Fri, 8 Oct 2021 07:31:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EA89C6103C; Fri, 8 Oct 2021 11:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633692545; bh=ot6VfK65sg2Y7YZeriZdOjctKXKEZ76qidoh2h4/l4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JnCeS8Tclb099P+PyJiQHzYOKwTYf2sTpOqdQFuK+4uhtv0MpEECCZ1jezVLoAnkm SFpjyadGY4Glpt9kQr7Og0MPYWTi03638fE2PkrETM8DRwKEX9VYSoG6+IpYywjgPQ r9Uqb5WX/o41c6eGmzVmUuWTbmJTKz/oeq1nuYDs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Christoph Hellwig , Ming Lei , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.9 6/8] scsi: sd: Free scsi_disk device via put_device() Date: Fri, 8 Oct 2021 13:27:43 +0200 Message-Id: <20211008112714.158150639@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008112713.941269121@linuxfoundation.org> References: <20211008112713.941269121@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei [ Upstream commit 265dfe8ebbabae7959060bd1c3f75c2473b697ed ] After a device is initialized via device_initialize() it should be freed via put_device(). sd_probe() currently gets this wrong, fix it up. Link: https://lore.kernel.org/r/20210906090112.531442-1-ming.lei@redhat.com Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/sd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 671bf1e03ee1..426f1b3aa15e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3179,15 +3179,16 @@ static int sd_probe(struct device *dev) } device_initialize(&sdkp->dev); - sdkp->dev.parent = dev; + sdkp->dev.parent = get_device(dev); sdkp->dev.class = &sd_disk_class; dev_set_name(&sdkp->dev, "%s", dev_name(dev)); error = device_add(&sdkp->dev); - if (error) - goto out_free_index; + if (error) { + put_device(&sdkp->dev); + goto out; + } - get_device(dev); dev_set_drvdata(dev, sdkp); get_device(&sdkp->dev); /* prevent release before async_schedule */ -- 2.33.0