Commit 287c2bb6 authored by Serge Semin's avatar Serge Semin Committed by Greg Kroah-Hartman

usb: usb251xb: Fix property_u32 NULL pointer dereference

The methods like of_property_read_u32 utilizing the specified
pointer permit only the pointer to a preallocated u32 storage as the
third argument. As a result the driver crashes on NULL pointer
dereference in case if "oc-delay-us" or "power-on-time-ms" declared
in dts file.
Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2818e13a
...@@ -347,7 +347,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, ...@@ -347,7 +347,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
struct device *dev = hub->dev; struct device *dev = hub->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
int len, err, i; int len, err, i;
u32 *property_u32 = NULL; u32 property_u32 = 0;
const u32 *cproperty_u32; const u32 *cproperty_u32;
const char *cproperty_char; const char *cproperty_char;
char str[USB251XB_STRING_BUFSIZE / 2]; char str[USB251XB_STRING_BUFSIZE / 2];
...@@ -424,16 +424,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, ...@@ -424,16 +424,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
if (of_get_property(np, "dynamic-power-switching", NULL)) if (of_get_property(np, "dynamic-power-switching", NULL))
hub->conf_data2 |= BIT(7); hub->conf_data2 |= BIT(7);
if (!of_property_read_u32(np, "oc-delay-us", property_u32)) { if (!of_property_read_u32(np, "oc-delay-us", &property_u32)) {
if (*property_u32 == 100) { if (property_u32 == 100) {
/* 100 us*/ /* 100 us*/
hub->conf_data2 &= ~BIT(5); hub->conf_data2 &= ~BIT(5);
hub->conf_data2 &= ~BIT(4); hub->conf_data2 &= ~BIT(4);
} else if (*property_u32 == 4000) { } else if (property_u32 == 4000) {
/* 4 ms */ /* 4 ms */
hub->conf_data2 &= ~BIT(5); hub->conf_data2 &= ~BIT(5);
hub->conf_data2 |= BIT(4); hub->conf_data2 |= BIT(4);
} else if (*property_u32 == 16000) { } else if (property_u32 == 16000) {
/* 16 ms */ /* 16 ms */
hub->conf_data2 |= BIT(5); hub->conf_data2 |= BIT(5);
hub->conf_data2 |= BIT(4); hub->conf_data2 |= BIT(4);
...@@ -500,8 +500,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, ...@@ -500,8 +500,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
} }
hub->power_on_time = USB251XB_DEF_POWER_ON_TIME; hub->power_on_time = USB251XB_DEF_POWER_ON_TIME;
if (!of_property_read_u32(np, "power-on-time-ms", property_u32)) if (!of_property_read_u32(np, "power-on-time-ms", &property_u32))
hub->power_on_time = min_t(u8, *property_u32 / 2, 255); hub->power_on_time = min_t(u8, property_u32 / 2, 255);
if (of_property_read_u16_array(np, "language-id", &hub->lang_id, 1)) if (of_property_read_u16_array(np, "language-id", &hub->lang_id, 1))
hub->lang_id = USB251XB_DEF_LANGUAGE_ID; hub->lang_id = USB251XB_DEF_LANGUAGE_ID;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment