Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp29589pxk; Tue, 15 Sep 2020 16:52:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYbmMoXdaDc7KYA38vvidez3lAYpXX6Ug6yQ8ipAUn5gMq7Hp2wMR2Trnr+ubm2ZZnEooh X-Received: by 2002:a50:fa88:: with SMTP id w8mr25189650edr.179.1600213926113; Tue, 15 Sep 2020 16:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600213926; cv=none; d=google.com; s=arc-20160816; b=lKcvbV8nShKGJOYKb69LIs8WVOaBl4CKppF+wlUDwYQ5EUyRCI5gToXNgsj9Frcnxp PdcbcNK3KSR0sks+ibdltj0R7GdxX8VULGA/aSPq5ZpbskkD68LU7UlhDa4o2A6CZKxL zP9tk4YMrUgckHMl6F8YJ7YzUPT+98HL8p5a34inJGSgTVGVSL/gaXG/BXZ5cT6a7oVX 7G4lrsaqCaGdRC6R0Wjk0QxY0Bwl73jNe2IAi3/RSxcVCe1k77NbbKRg/CdR1iccmtio ARIzXbNzkmA8mVKSu6LSkeoQTPrFrWdMNtxDRgSrrMK98tcvFj3Fy5ZlZR/KyJBQv9jj E3kQ== 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=oRTBP54XEOcKSBc4uBzOawLy9/kA4irqgmPqtWiSNNo=; b=acAw6lC7ntrGUz24OJ2ru+kCRckSwN0V15405dH+XoJ6HmhQSXw6y0/GNXpDrQqZJ7 IYpdE6jfTBI9jUOrCsMMSxb7VU9y6cW/nqeXnLdt6nO69ZzaTBY/W9+jbHIYCzbfqBwx Y93gNiZL7wEOmu0UskP2dLOMOJZFsY9NUfGOZx0EvGXfW3PJxw8Rm/gq1atVdc4Nm0+4 Czss2X3NWvPI3vrncCBN7vKoxxy3fjTnhjKgjXX7XwPDm7vubEWQ4KJcuLiREJsFH32y NkUWKFcZ/2O6hl0sbsi+qYX7b14Oq2fLHsEggHacpWdtoqu6d9fzzgC+/jWPaIyU6o+V RsAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="I/Yq2nI5"; 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=fail (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 c17si10651541ejx.205.2020.09.15.16.51.44; Tue, 15 Sep 2020 16:52: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=@kernel.org header.s=default header.b="I/Yq2nI5"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727259AbgIOXtK (ORCPT + 99 others); Tue, 15 Sep 2020 19:49:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:46458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbgIOOcn (ORCPT ); Tue, 15 Sep 2020 10:32:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 7B11923BCB; Tue, 15 Sep 2020 14:24:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179859; bh=8nQpmBYjaZnEjQBC/K8dR/WQQkqe0zsoRPOKY9J4eXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/Yq2nI5zazmOE7+BuZp2V9YLIBLyMyuTdmj9FKv6WDsr+YKyeNLXb0x3HZweB+bu hF1mgn7HpbD9f/KwKUbwG0Q5er08FvBmhOPrTcOSyYqaTk8+vvcKjXEqL+pWsaBgsq rxiT2y8carrOEVWz99sKFHvpEFumEiNqPhP+UU9o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe , Md Haris Iqbal , Jack Wang , Sasha Levin Subject: [PATCH 5.8 014/177] RDMA/rtrs-srv: Replace device_register with device_initialize and device_add Date: Tue, 15 Sep 2020 16:11:25 +0200 Message-Id: <20200915140654.322625647@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140653.610388773@linuxfoundation.org> References: <20200915140653.610388773@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: Md Haris Iqbal [ Upstream commit baa5b28b7a474f66a511ebf71a2ade510652a2f6 ] There are error cases when we will call free_srv before device kobject is initialized; in such cases calling put_device generates the following warning: kobject: '(null)' (000000009f5445ed): is not initialized, yet kobject_put() is being called. So call device_initialize() only once when the server is allocated. If we end up calling put_srv() and subsequently free_srv(), our call to put_device() would result in deletion of the obj. Call device_add() later when we actually have a connection. Correspondingly, call device_del() instead of device_unregister() when srv->dev_ref falls to 0. Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality") Link: https://lore.kernel.org/r/20200811092722.2450-1-haris.iqbal@cloud.ionos.com Suggested-by: Jason Gunthorpe Signed-off-by: Md Haris Iqbal Reviewed-by: Jack Wang Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 8 ++++---- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c index 3d7877534bcc9..2f981ae970767 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c @@ -182,16 +182,16 @@ static int rtrs_srv_create_once_sysfs_root_folders(struct rtrs_srv_sess *sess) * sysfs files are created */ dev_set_uevent_suppress(&srv->dev, true); - err = device_register(&srv->dev); + err = device_add(&srv->dev); if (err) { - pr_err("device_register(): %d\n", err); + pr_err("device_add(): %d\n", err); goto put; } srv->kobj_paths = kobject_create_and_add("paths", &srv->dev.kobj); if (!srv->kobj_paths) { err = -ENOMEM; pr_err("kobject_create_and_add(): %d\n", err); - device_unregister(&srv->dev); + device_del(&srv->dev); goto unlock; } dev_set_uevent_suppress(&srv->dev, false); @@ -216,7 +216,7 @@ rtrs_srv_destroy_once_sysfs_root_folders(struct rtrs_srv_sess *sess) kobject_del(srv->kobj_paths); kobject_put(srv->kobj_paths); mutex_unlock(&srv->paths_mutex); - device_unregister(&srv->dev); + device_del(&srv->dev); } else { mutex_unlock(&srv->paths_mutex); } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index a219bd1bdbc26..b61a18e57aeba 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1336,6 +1336,7 @@ static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx, uuid_copy(&srv->paths_uuid, paths_uuid); srv->queue_depth = sess_queue_depth; srv->ctx = ctx; + device_initialize(&srv->dev); srv->chunks = kcalloc(srv->queue_depth, sizeof(*srv->chunks), GFP_KERNEL); -- 2.25.1