Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf

2 messages, 2 authors, 2016-01-20 · open the first message on its own page

Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2016-01-20 09:38:23

On Wed, 2016-01-20 at 14:49 +0800, Yankejian (Hackim Yim) wrote:
quoted
quoted
+
quoted
quoted
quoted
+	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.
AFAIR it's designed in a way you don't need to do any additional
locking or synchronization.

-- 
Andy Shevchenko [off-list ref]
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf

From: Yankejian (Hackim Yim) <hidden>
Date: 2016-01-20 11:12:10


On 2016/1/20 17:36, Andy Shevchenko wrote:
On Wed, 2016-01-20 at 14:49 +0800, Yankejian (Hackim Yim) wrote:
quoted
quoted
quoted
+
quoted
quoted
quoted
+	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.
AFAIR it's designed in a way you don't need to do any additional
locking or synchronization.
really? if so, that is great.
could you sent me an example.
thanks very much. Andy.

Best Regards,
Kejian Yan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help