diff mbox series

[LEDE-DEV] Fix NULL pointer dereferece in at803x_link_change_notify()

Message ID 20170928132742.ectbissmx2am24za@ppc.Dlink
State Changes Requested
Headers show
Series [LEDE-DEV] Fix NULL pointer dereferece in at803x_link_change_notify() | expand

Commit Message

Andrey Jr. Melnikov Sept. 28, 2017, 1:27 p.m. UTC
Hello.

Fix NULL pointer dereferece in at803x_link_change_notify().

Signed-Off-by: "Andrey Jr. Melnikov" <temnota.am@gmail.com>

--

Comments

John Crispin Oct. 6, 2017, 5:05 p.m. UTC | #1
Hi,

the subject is missing the prefix


On 28/09/17 15:27, Andrey Jr. Melnikov wrote:
> Hello.
please drop the line above

> Fix NULL pointer dereferece in at803x_link_change_notify().
you just copied the subject here. please explain the bug instead.

     John
> Signed-Off-by: "Andrey Jr. Melnikov" <temnota.am@gmail.com>
>
> --
>
> diff --git a/target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch b/target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch
> index 2244f882e7..efc8502bcd 100644
> --- a/target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch
> +++ b/target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch
> @@ -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);
>
>
> _______________________________________________
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
diff mbox series

Patch

diff --git a/target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch b/target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch
index 2244f882e7..efc8502bcd 100644
--- a/target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch
+++ b/target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch
@@ -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);