From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Amir Vadai <amirv-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Tal Alon <talal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH V2 for-next 3/5] IB/core: Call ib_unregister_mad_agent() only for valid agents
Date: Thu, 5 Feb 2015 10:43:37 -0700 [thread overview]
Message-ID: <20150205174337.GB31711@obsidianresearch.com> (raw)
In-Reply-To: <1423131138-19060-4-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
On Thu, Feb 05, 2015 at 12:12:16PM +0200, Or Gerlitz wrote:
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index 82a7dd8..6be0d2c 100644
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -907,7 +907,7 @@ int mlx4_ib_mad_init(struct mlx4_ib_dev *dev)
> err:
> for (p = 0; p < dev->num_ports; ++p)
> for (q = 0; q <= 1; ++q)
> - if (dev->send_agent[p][q])
> + if (!IS_ERR(dev->send_agent[p][q]))
> ib_unregister_mad_agent(dev->send_agent[p][q]);
This doesn't really address my comment. I said the check for err ptr
only belongs after ib_register_mad_agent, I'm also not sure why these
few call sites were picked for this change ...
It didn't take long to see that mlx4 already does:
int mlx4_ib_mad_init(struct mlx4_ib_dev *dev)
{
struct ib_mad_agent *agent;
int p, q;
int ret;
enum rdma_link_layer ll;
for (p = 0; p < dev->num_ports; ++p) {
ll = rdma_port_get_link_layer(&dev->ib_dev, p + 1);
for (q = 0; q <= 1; ++q) {
if (ll == IB_LINK_LAYER_INFINIBAND) {
agent = ib_register_mad_agent(&dev->ib_dev, p + 1,
q ? IB_QPT_GSI : IB_QPT_SMI,
NULL, 0, send_handler,
NULL, NULL);
if (IS_ERR(agent)) {
ret = PTR_ERR(agent);
goto err;
}
dev->send_agent[p][q] = agent;
} else
dev->send_agent[p][q] = NULL;
}
}
I can't see how send_agent can ever contain err_ptr - and the above is
a good idiom.
I leave checking the rest up to you.
[The set to null is either redundent or there is another bug here
because the err unwind blindly unregisters everything]
Again: err_ptr checks belong after ib_register_mad_agent - not at the
unregister, err_ptr values should not be put into long term storage in
the first place.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-02-05 17:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 10:12 [PATCH V2 for-next 0/5] IB core fixes 29-Jan-2015 Or Gerlitz
[not found] ` <1423131138-19060-1-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-02-05 10:12 ` [PATCH V2 for-next 1/5] IB/core: When marshaling ucma path from user-space, clear unused fields Or Gerlitz
2015-02-05 10:12 ` [PATCH V2 for-next 2/5] IB/core: Fixes in ib_sa_add_one error flow Or Gerlitz
2015-02-05 10:12 ` [PATCH V2 for-next 3/5] IB/core: Call ib_unregister_mad_agent() only for valid agents Or Gerlitz
[not found] ` <1423131138-19060-4-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-02-05 17:43 ` Jason Gunthorpe [this message]
2015-02-05 10:12 ` [PATCH V2 for-next 4/5] IB/core: Make sure that the PSN does not overflow Or Gerlitz
2015-02-05 10:12 ` [PATCH V2 for-next 5/5] IB/core: Fix deadlock on uverbs modify_qp error flow Or Gerlitz
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=20150205174337.GB31711@obsidianresearch.com \
--to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
--cc=amirv-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=talal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox