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