From: Dan Carpenter <dan.carpenter@oracle.com>
To: jgg@ziepe.ca
Cc: linux-rdma@vger.kernel.org
Subject: [bug report] RDMA/devices: Re-organize device.c locking
Date: Tue, 10 Aug 2021 12:18:42 +0300 [thread overview]
Message-ID: <20210810085252.GC23998@kili> (raw)
Hello Jason Gunthorpe,
The patch 921eab1143aa: "RDMA/devices: Re-organize device.c locking"
from Feb 6, 2019, leads to the following static checker warning:
drivers/infiniband/core/device.c:712 add_client_context()
warn: missing error code 'ret'
drivers/infiniband/core/device.c
689 static int add_client_context(struct ib_device *device,
690 struct ib_client *client)
691 {
692 int ret = 0;
693
694 if (!device->kverbs_provider && !client->no_kverbs_req)
695 return 0;
696
697 down_write(&device->client_data_rwsem);
698 /*
699 * So long as the client is registered hold both the client and device
700 * unregistration locks.
701 */
702 if (!refcount_inc_not_zero(&client->uses))
703 goto out_unlock;
704 refcount_inc(&device->refcount);
705
706 /*
707 * Another caller to add_client_context got here first and has already
708 * completely initialized context.
709 */
710 if (xa_get_mark(&device->client_data, client->client_id,
711 CLIENT_DATA_REGISTERED))
--> 712 goto out;
Hard to tell if ret should be zero or negative.
713
714 ret = xa_err(xa_store(&device->client_data, client->client_id, NULL,
715 GFP_KERNEL));
716 if (ret)
717 goto out;
718 downgrade_write(&device->client_data_rwsem);
719 if (client->add) {
720 if (client->add(device)) {
721 /*
722 * If a client fails to add then the error code is
723 * ignored, but we won't call any more ops on this
724 * client.
725 */
726 xa_erase(&device->client_data, client->client_id);
727 up_read(&device->client_data_rwsem);
728 ib_device_put(device);
729 ib_client_put(client);
730 return 0;
731 }
732 }
733
734 /* Readers shall not see a client until add has been completed */
735 xa_set_mark(&device->client_data, client->client_id,
736 CLIENT_DATA_REGISTERED);
737 up_read(&device->client_data_rwsem);
738 return 0;
739
740 out:
741 ib_device_put(device);
742 ib_client_put(client);
743 out_unlock:
744 up_write(&device->client_data_rwsem);
745 return ret;
746 }
regards,
dan carpenter
next reply other threads:[~2021-08-10 9:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 9:18 Dan Carpenter [this message]
2021-08-25 16:34 ` [bug report] RDMA/devices: Re-organize device.c locking Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210810085252.GC23998@kili \
--to=dan.carpenter@oracle.com \
--cc=jgg@ziepe.ca \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.