Re: [PATCH] usb: usb-storage doesn't support dynamic id currently, the patch disables the feature to fix an oops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 12 Jan 2012, Huajun Li wrote:

> >> + � � index = id - usb_storage_usb_ids;
> >> + � � size = sizeof(us_unusual_dev_list) / sizeof(struct us_unusual_dev);
> >> + � � if (index < 0 || index >= size - 1) {
> >
> > No, no! �This is totally bogus. �According to the C language
> > specification, if id doesn't point to a member of the
> > usb_storage_usb_ids array then the difference id - usb_storage_usb_ids
> > is meaningless. �You can't depend on it having any particular value at
> > all.
> >
> > The right way to do the test is like this:
> >
> > � � � �size = ARRAY_SIZE(us_unusual_dev_list);
> > � � � �if (id < usb_storage_usb_ids || id >= usb_storage_usb_ids + size) {
> >
> 
> Will change it although it could work per my test.
> 
> However, there is a terminating entry  in  usb_storage_usb_ids, so
> maybe it should be changed to below one, right ?
>          if (id < usb_storage_usb_ids || id >= usb_storage_usb_ids + size - 1) {

This doesn't matter.  The terminating entry is empty, so id will never 
point to it.

Alan Stern

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux