Skip to content

Commit cd06095

Browse files
fangxiaozhigregkh
authored andcommitted
USB: storage: properly handle the endian issues of idProduct
1. The idProduct is little endian, so make sure its value to be compatible with the current CPU. Make no break on big endian processors. Signed-off-by: fangxiaozhi <huananhu@huawei.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9742aec commit cd06095

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/usb/storage/initializers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static int usb_stor_huawei_dongles_pid(struct us_data *us)
147147
int idProduct;
148148

149149
idesc = &us->pusb_intf->cur_altsetting->desc;
150-
idProduct = us->pusb_dev->descriptor.idProduct;
150+
idProduct = le16_to_cpu(us->pusb_dev->descriptor.idProduct);
151151
/* The first port is CDROM,
152152
* means the dongle in the single port mode,
153153
* and a switch command is required to be sent. */
@@ -169,7 +169,7 @@ int usb_stor_huawei_init(struct us_data *us)
169169
int result = 0;
170170

171171
if (usb_stor_huawei_dongles_pid(us)) {
172-
if (us->pusb_dev->descriptor.idProduct >= 0x1446)
172+
if (le16_to_cpu(us->pusb_dev->descriptor.idProduct) >= 0x1446)
173173
result = usb_stor_huawei_scsi_init(us);
174174
else
175175
result = usb_stor_huawei_feature_init(us);

0 commit comments

Comments
 (0)