From: "Yankejian (Hackim Yim)" <yankejian@huawei.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Yisen Zhuang <Yisen.zhuang@huawei.com>,
davem@davemloft.net, robh+dt@kernel.org, pawel.moll@arm.com,
mark.rutland@arm.com, ijc+devicetree@hellion.org.uk,
galak@codeaurora.org, catalin.marinas@arm.com,
will.deacon@arm.com, huangdaode@hisilicon.com,
liguozhu@huawei.com, arnd@arndb.de, fengguang.wu@intel.com,
salil.mehta@huawei.com, lisheng011@huawei.com
Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org,
linuxarm@huawei.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
Date: Wed, 20 Jan 2016 14:49:16 +0800 [thread overview]
Message-ID: <569F2DEC.9040209@huawei.com> (raw)
In-Reply-To: <1452764635.2521.28.camel@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]
On 2016/1/14 17:43, Andy Shevchenko wrote:
>>
>>> > > --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> > > +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> > > @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>>> > > int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>>> > > {
>>> > > struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
>>> > > + static atomic_t id = ATOMIC_INIT(-1);
>>> > >
>>> > > switch (dsaf_dev->dsaf_ver) {
>>> > > case AE_VERSION_1:
>>> > > @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
>>> > > *dsaf_dev)
>>> > > default:
>>> > > break;
>>> > > }
>>> > > +
>>> > > + snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>> > > DSAF_DEVICE_NAME,
>>> > > + (int)atomic_inc_return(&id));
> If you bind/unbind device enough times you may get an overflow and end
> up with name of existing device (if you have 1+ of them in the system).
>
> To avoid such situation better to use IDA/IDR framework.
>
Hi, Andy
Thanks again for your suggestion.
It seems that using IDA/IDR framework is better, but all of the functions must be serialized by lock.
And actually, we confirm that it won't be overflow in our analysis before we implemented it.
Best Regards,
Kejian Yan
[-- Attachment #2: Type: text/html, Size: 3149 bytes --]
next prev parent reply other threads:[~2016-01-20 6:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-13 3:14 [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf Kejian Yan
2016-01-14 3:00 ` Yisen Zhuang
[not found] ` <56970F48.9060504-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-01-14 9:43 ` Andy Shevchenko
[not found] ` <1452764635.2521.28.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-01-18 11:35 ` Yankejian (Hackim Yim)
2016-01-20 6:49 ` Yankejian (Hackim Yim) [this message]
[not found] ` <569F2DEC.9040209-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-01-20 9:36 ` Andy Shevchenko
2016-01-20 11:10 ` Yankejian (Hackim Yim)
[not found] ` <1452654880-28980-1-git-send-email-yankejian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-01-15 2:28 ` Rob Herring
-- strict thread matches above, loose matches on Subject: below --
2016-01-13 3:01 Kejian Yan
2016-01-13 2:52 ` Yankejian (Hackim Yim)
2016-01-13 2:54 ` David Miller
2016-01-13 3:00 ` Yankejian (Hackim Yim)
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=569F2DEC.9040209@huawei.com \
--to=yankejian@huawei.com \
--cc=Yisen.zhuang@huawei.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=fengguang.wu@intel.com \
--cc=galak@codeaurora.org \
--cc=huangdaode@hisilicon.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=liguozhu@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=lisheng011@huawei.com \
--cc=mark.rutland@arm.com \
--cc=netdev@vger.kernel.org \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=salil.mehta@huawei.com \
--cc=will.deacon@arm.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).