ar71xx: Fix NULL pointer dereferece in at803x_link_change_notify()

Check pdata pointer before use to avoid OOPS if dev_get_platdata() return
NULL.

Signed-off-by: Andrey Jr. Melnikov <temnota.am@gmail.com>
openwrt-18.06
Andrey Jr. Melnikov 2017-10-08 00:00:28 +03:00 committed by John Crispin
parent 9c9f7b0434
commit 2cb8f0a4cf
1 changed files with 2 additions and 2 deletions

View File

@ -42,7 +42,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
*/
if (phydev->state == PHY_NOLINK) {
- if (priv->gpiod_reset && !priv->phy_reset) {
+ if ((priv->gpiod_reset || pdata->has_reset_gpio) &&
+ if ((priv->gpiod_reset || (pdata && pdata->has_reset_gpio)) &&
+ !priv->phy_reset) {
struct at803x_context context;
@ -52,7 +52,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
- msleep(1);
- gpiod_set_value(priv->gpiod_reset, 0);
- msleep(1);
+ if (pdata->has_reset_gpio) {
+ if (pdata && pdata->has_reset_gpio) {
+ gpio_set_value_cansleep(pdata->reset_gpio, 0);
+ msleep(1);
+ gpio_set_value_cansleep(pdata->reset_gpio, 1);