From: Doug Ledford <dledford@redhat.com>
To: Selvin Xavier <selvin.xavier@broadcom.com>, linux-rdma@vger.kernel.org
Cc: netdev@vger.kernel.org, michael.chan@broadcom.com,
Eddie Wai <eddie.wai@broadcom.com>,
Devesh Sharma <devesh.sharma@broadcom.com>,
Somnath Kotur <somnath.kotur@broadcom.com>,
Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Subject: Re: [PATCH for bnxt_re V4 03/21] RDMA/bnxt_re: register with the NIC driver
Date: Mon, 06 Feb 2017 15:26:20 -0500 [thread overview]
Message-ID: <1486412780.86943.5.camel@redhat.com> (raw)
In-Reply-To: <1482320530-5344-4-git-send-email-selvin.xavier@broadcom.com>
[-- Attachment #1: Type: text/plain, Size: 1771 bytes --]
On Wed, 2016-12-21 at 03:41 -0800, Selvin Xavier wrote:
> +static void bnxt_re_dev_remove(struct bnxt_re_dev *rdev)
> +{
> + int i = BNXT_RE_REF_WAIT_COUNT;
> +
> + /* Wait for rdev refcount to come down */
> + while ((atomic_read(&rdev->ref_count) > 1) && i--)
> + msleep(100);
> +
> + if (atomic_read(&rdev->ref_count) > 1)
> + dev_err(rdev_to_dev(rdev),
> + "Failed waiting for ref count to deplete %d",
> + atomic_read(&rdev->ref_count));
> +
> + atomic_set(&rdev->ref_count, 0);
> + dev_put(rdev->netdev);
> + rdev->netdev = NULL;
> +
> + mutex_lock(&bnxt_re_dev_lock);
> + list_del_rcu(&rdev->list);
> + mutex_unlock(&bnxt_re_dev_lock);
> +
> + synchronize_rcu();
> + flush_workqueue(bnxt_re_wq);
> +
> + ib_dealloc_device(&rdev->ibdev);
> + /* rdev is gone */
> +}
This looks bad. Either your ref counting is right, and your ref count
should go to 1, or you have an issue that won't be helped by forcibly
removing the device. In its current form, this looks like an oopser
waiting to happen.
If you know your ref counting is right, then simply wait until it goes
to 1, don't have this bailout logic. If you truly need to bailout for
some reason, then you need to not free things. Better to shutdown then
leak and live than release and have a use after free data corrupter.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-02-06 20:26 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-21 11:41 [PATCH for bnxt_re V4 00/21] Broadcom RoCE Driver (bnxt_re) Selvin Xavier
2016-12-21 11:41 ` [PATCH for bnxt_re V4 01/21] RDMA/bnxt_re: Add bnxt_re RoCE driver files Selvin Xavier
2016-12-21 11:41 ` [PATCH for bnxt_re V4 02/21] RDMA/bnxt_re: Introducing autogenerated Host Software Interface(hsi) file Selvin Xavier
2016-12-21 11:41 ` [PATCH for bnxt_re V4 03/21] RDMA/bnxt_re: register with the NIC driver Selvin Xavier
2017-01-18 10:11 ` Leon Romanovsky
2017-02-06 20:26 ` Doug Ledford [this message]
2017-02-10 11:41 ` Selvin Xavier
2016-12-21 11:41 ` [PATCH for bnxt_re V4 06/21] RDMA/bnxt_re: Support for PD, ucontext and mmap verbs Selvin Xavier
2016-12-21 11:41 ` [PATCH for bnxt_re V4 07/21] RDMA/bnxt_re: Support for query and modify device verbs Selvin Xavier
[not found] ` <1482320530-5344-1-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-21 11:41 ` [PATCH for bnxt_re V4 04/21] RDMA/bnxt_re: Enabling RoCE control path Selvin Xavier
2016-12-21 11:41 ` [PATCH for bnxt_re V4 05/21] RDMA/bnxt_re: Adding Notification Queue support Selvin Xavier
2016-12-21 11:41 ` [PATCH for bnxt_re V4 08/21] RDMA/bnxt_re: Adding support for port related verbs Selvin Xavier
2016-12-21 11:41 ` [PATCH for bnxt_re V4 09/21] RDMA/bnxt_re: Support for GID " Selvin Xavier
2017-01-18 9:50 ` Leon Romanovsky
2016-12-21 11:41 ` [PATCH for bnxt_re V4 10/21] RDMA/bnxt_re: Support for CQ verbs Selvin Xavier
[not found] ` <1482320530-5344-11-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-01-18 8:19 ` Leon Romanovsky
2016-12-21 11:42 ` [PATCH for bnxt_re V4 11/21] RDMA/bnxt_re: Support for AH verbs Selvin Xavier
2016-12-21 11:42 ` [PATCH for bnxt_re V4 14/21] RDMA/bnxt_re: Support post_send verb Selvin Xavier
2016-12-21 11:42 ` [PATCH for bnxt_re V4 15/21] RDMA/bnxt_re: Support post_recv Selvin Xavier
2017-01-24 11:59 ` Leon Romanovsky
2016-12-21 11:42 ` [PATCH for bnxt_re V4 16/21] RDMA/bnxt_re: Support poll_cq verb Selvin Xavier
2016-12-21 11:42 ` [PATCH for bnxt_re V4 17/21] RDMA/bnxt_re: Handling dispatching of events to IB stack Selvin Xavier
[not found] ` <1482320530-5344-18-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-01-24 12:18 ` Leon Romanovsky
2017-01-25 9:03 ` Selvin Xavier
2016-12-21 11:42 ` [PATCH for bnxt_re V4 18/21] RDMA/bnxt_re: Support for DCB Selvin Xavier
2016-12-21 11:42 ` [PATCH for bnxt_re V4 21/21] RDMA/bnxt_re: Add bnxt_re driver build support Selvin Xavier
2017-02-07 15:27 ` [PATCH for bnxt_re V4 00/21] Broadcom RoCE Driver (bnxt_re) Doug Ledford
2016-12-21 11:42 ` [PATCH for bnxt_re V4 12/21] RDMA/bnxt_re: Support memory registration verbs Selvin Xavier
2016-12-21 11:42 ` [PATCH for bnxt_re V4 13/21] RDMA/bnxt_re: Support QP verbs Selvin Xavier
2017-01-18 9:16 ` Leon Romanovsky
2016-12-21 11:42 ` [PATCH for bnxt_re V4 19/21] RDMA/bnxt_re: Set uverbs command mask Selvin Xavier
2016-12-21 11:42 ` [PATCH for bnxt_re V4 20/21] RDMA/bnxt_re: Add QP event handling Selvin Xavier
2017-01-24 12:20 ` Leon Romanovsky
[not found] ` <20170124122008.GH6005-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-01-25 9:04 ` Selvin Xavier
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=1486412780.86943.5.camel@redhat.com \
--to=dledford@redhat.com \
--cc=devesh.sharma@broadcom.com \
--cc=eddie.wai@broadcom.com \
--cc=linux-rdma@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=selvin.xavier@broadcom.com \
--cc=somnath.kotur@broadcom.com \
--cc=sriharsha.basavapatna@broadcom.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).