From: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>,
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>,
Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>,
MikeMarciniszyn
<infinipath-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH RE-RESEND V2 for-next 3/5] IB/core: Call ib_unregister_mad_agent() only for valid agents
Date: Thu, 19 Feb 2015 11:13:30 +0200 [thread overview]
Message-ID: <54E5A93A.8060501@mellanox.com> (raw)
In-Reply-To: <1424181596.32606.43.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
On 17/2/2015 3:59 PM, Yann Droneaud wrote:
> Hi,
>
> Le lundi 16 février 2015 à 22:28 +0100, Yann Droneaud a écrit :
>> Le jeudi 05 février 2015 à 13:53 +0200, Or Gerlitz a écrit :
>>> From: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>>>
>>> In some error flows, ib_mad_unregister_agent is being invoked also in cases where
>> ^^^^^^^^^^^^^^^^^^^^^^^
>> ib_unregister_mad_agent()
>>
>>> the ib_mad_register_agent call failed (resulting in an illegal pointer in the
>> ^^^^^^^^^^^^^^^^^^^^^
>> ib_register_mad_agent()
>>
>>> agent field). This causes a kernel crash in the error flow.
>>>
>>> Fix this by calling ib_unregister_mad_agent only for cases where
>>> ib_register_mad_agent succeeded.
>>>
>> The code was checking for struct ib_mad_agent *agent not being NULL,
>> while ib_register_mad_agent() returns a ERR_PTR() in case of error
>> ... bad :(
>>
> After reading Jason's comments [1], I don't understand the purpose of
> this patch. How can an ERR_PTR() value be present in the arrays ?
>
> A quick review makes me think that mthca and mlx4 error paths lacks NULL
> assignment after calling ib_unregister_mad_agent(). In other words, qib
> might be correct while the others should be fixed.
You are right. Seems like I missed things here.
I'll fix it and send a new version soon.
>
> [1] http://mid.gmane.org/20150205174337.GB31711-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
>
>>> Signed-off-by: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>>> Signed-off-by: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>>> ---
>>> drivers/infiniband/hw/mlx4/mad.c | 2 +-
>>> drivers/infiniband/hw/mthca/mthca_mad.c | 2 +-
>>> drivers/infiniband/hw/qib/qib_mad.c | 2 +-
>>> 3 files changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
>>> index 82a7dd8..6be0d2c 100644
>>> --- a/drivers/infiniband/hw/mlx4/mad.c
>>> +++ 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]);
>>>
>>> return ret;
>>> diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
>>> index 8881fa3..5f1a7ce 100644
>>> --- a/drivers/infiniband/hw/mthca/mthca_mad.c
>>> +++ b/drivers/infiniband/hw/mthca/mthca_mad.c
>>> @@ -317,7 +317,7 @@ int mthca_create_agents(struct mthca_dev *dev)
>>> err:
>>> for (p = 0; p < dev->limits.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]);
>>>
>>> return ret;
>>> diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
>>> index 636be11..6c7cc80 100644
>>> --- a/drivers/infiniband/hw/qib/qib_mad.c
>>> +++ b/drivers/infiniband/hw/qib/qib_mad.c
>>> @@ -2499,7 +2499,7 @@ int qib_create_agents(struct qib_ibdev *dev)
>>> err:
>>> for (p = 0; p < dd->num_pports; p++) {
>>> ibp = &dd->pport[p].ibport_data;
>>> - if (ibp->send_agent) {
>>> + if (!IS_ERR(ibp->send_agent)) {
>>> agent = ibp->send_agent;
>>> ibp->send_agent = NULL;
>>> ib_unregister_mad_agent(agent);
> Regards.
>
--
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-19 9:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 11:53 [PATCH RE-RESEND V2 for-next 0/5] IB core fixes 29-Jan-2015 Or Gerlitz
[not found] ` <1423137232-24587-1-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-02-05 11:53 ` [PATCH RE-RESEND V2 for-next 1/5] IB/core: When marshaling ucma path from user-space, clear unused fields Or Gerlitz
[not found] ` <1423137232-24587-2-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-02-17 19:24 ` Or Gerlitz
2015-02-05 11:53 ` [PATCH RE-RESEND V2 for-next 2/5] IB/core: Fixes in ib_sa_add_one error flow Or Gerlitz
2015-02-05 11:53 ` [PATCH RE-RESEND V2 for-next 3/5] IB/core: Call ib_unregister_mad_agent() only for valid agents Or Gerlitz
[not found] ` <1423137232-24587-4-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-02-16 21:28 ` Yann Droneaud
[not found] ` <1424122092.32606.36.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
2015-02-17 13:59 ` Yann Droneaud
[not found] ` <1424181596.32606.43.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
2015-02-19 9:13 ` Majd Dibbiny [this message]
2015-02-05 11:53 ` [PATCH RE-RESEND V2 for-next 4/5] IB/core: Make sure that the PSN does not overflow Or Gerlitz
[not found] ` <1423137232-24587-5-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-02-05 22:27 ` Weiny, Ira
[not found] ` <2807E5FD2F6FDA4886F6618EAC48510E0CC1DE52-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-02-06 15:28 ` Or Gerlitz
2015-02-16 21:22 ` Yann Droneaud
[not found] ` <1424121752.32606.32.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
2015-02-16 22:06 ` Weiny, Ira
2015-02-05 11:53 ` [PATCH RE-RESEND V2 for-next 5/5] IB/core: Fix deadlock on uverbs modify_qp error flow Or Gerlitz
[not found] ` <1423137232-24587-6-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-02-16 21:17 ` Yann Droneaud
2015-02-18 5:03 ` Or Gerlitz
[not found] ` <54E41D3E.6020809-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-02-18 6:07 ` Roland Dreier
[not found] ` <CAG4TOxOhnc_ihooLyKJ09P90RMM4MbcWS5McwNOMV4gQ+Ls4Qg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-19 8:31 ` 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=54E5A93A.8060501@mellanox.com \
--to=majd-vpraknaxozvwk0htik3j/w@public.gmane.org \
--cc=amirv-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=infinipath-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@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 \
--cc=ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@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