All of lore.kernel.org
 help / color / mirror / Atom feed
* fsl/fman: Clarification for implementation details in dtsec_config()
@ 2016-01-13 21:20 ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2016-01-13 21:20 UTC (permalink / raw)
  To: netdev, Andrew Lunn, Dan Carpenter, David S. Miller, Igal Liberman
  Cc: linux-kernel, kernel-janitors, Julia Lawall

Hello,

The Coccinelle semantic patch "deref_null.cocci" pointed out a potential
problem in the implementation of the function "dtsec_config" (lines 1434-1439):
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/freescale/fman/fman_dtsec.c?id=e5a03bfd873c29eb786655ef2e95e53ed242b404#n1434
…
	dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
	if (!dtsec->tbiphy) {
		pr_err("of_phy_find_device (TBI PHY) failed\n");
		put_device(&dtsec->tbiphy->mdio.dev);
		goto err_dtsec_drv_param;
	}
…

If the pointer "dtsec->tbiphy" is NULL, then it will especially matter
if the shown address computation will succeed.
Should the call of the function "put_device" be removed,
or was another argument intended?

Regards,
Markus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* fsl/fman: Clarification for implementation details in dtsec_config()
@ 2016-01-13 21:20 ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2016-01-13 21:20 UTC (permalink / raw)
  To: netdev, Andrew Lunn, Dan Carpenter, David S. Miller, Igal Liberman
  Cc: linux-kernel, kernel-janitors, Julia Lawall

Hello,

The Coccinelle semantic patch "deref_null.cocci" pointed out a potential
problem in the implementation of the function "dtsec_config" (lines 1434-1439):
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/freescale/fman/fman_dtsec.c?idåa03bfd873c29eb786655ef2e95e53ed242b404#n1434
…
	dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
	if (!dtsec->tbiphy) {
		pr_err("of_phy_find_device (TBI PHY) failed\n");
		put_device(&dtsec->tbiphy->mdio.dev);
		goto err_dtsec_drv_param;
	}
…

If the pointer "dtsec->tbiphy" is NULL, then it will especially matter
if the shown address computation will succeed.
Should the call of the function "put_device" be removed,
or was another argument intended?

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: fsl/fman: Clarification for implementation details in dtsec_config()
  2016-01-13 21:20 ` SF Markus Elfring
@ 2016-01-13 21:35   ` Dan Carpenter
  -1 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2016-01-13 21:35 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, Andrew Lunn, David S. Miller, Igal Liberman,
	linux-kernel, kernel-janitors, Julia Lawall

I think you can remove the put_device() line.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: fsl/fman: Clarification for implementation details in dtsec_config()
@ 2016-01-13 21:35   ` Dan Carpenter
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2016-01-13 21:35 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, Andrew Lunn, David S. Miller, Igal Liberman,
	linux-kernel, kernel-janitors, Julia Lawall

I think you can remove the put_device() line.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: fsl/fman: Clarification for implementation details in dtsec_config()
  2016-01-13 21:35   ` Dan Carpenter
@ 2016-01-13 22:09     ` Andrew Lunn
  -1 siblings, 0 replies; 12+ messages in thread
From: Andrew Lunn @ 2016-01-13 22:09 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, netdev, David S. Miller, Igal Liberman,
	linux-kernel, kernel-janitors, Julia Lawall

On Thu, Jan 14, 2016 at 12:35:37AM +0300, Dan Carpenter wrote:
> I think you can remove the put_device() line.

Agreed.

of_phy_find_device() only does a get_device() when it finds a matching
device.

	Andrew

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: fsl/fman: Clarification for implementation details in dtsec_config()
@ 2016-01-13 22:09     ` Andrew Lunn
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Lunn @ 2016-01-13 22:09 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, netdev, David S. Miller, Igal Liberman,
	linux-kernel, kernel-janitors, Julia Lawall

On Thu, Jan 14, 2016 at 12:35:37AM +0300, Dan Carpenter wrote:
> I think you can remove the put_device() line.

Agreed.

of_phy_find_device() only does a get_device() when it finds a matching
device.

	Andrew

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] fsl/fman: Delete one function call "put_device" in dtsec_config()
  2016-01-13 22:09     ` Andrew Lunn
@ 2016-01-14 15:00       ` SF Markus Elfring
  -1 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2016-01-14 15:00 UTC (permalink / raw)
  To: Andrew Lunn, Dan Carpenter, David S. Miller, Igal Liberman, netdev
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 15:46:28 +0100

The Coccinelle semantic patch script "deref_null.cocci" pointed a problem
out in the implementation of the function "dtsec_config".

A null pointer was assigned to the data structure member "tbiphy" of the
variable "dtsec" if a matching device was not found.
A call of the function "put_device" was unnecessary then because
a previous call of the function "get_device" was not triggered.
Thus remove the function call "put_device" after the printing of the
desired error message.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/fman/fman_dtsec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 6b1261c..7c92eb8 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -1434,7 +1434,6 @@ struct fman_mac *dtsec_config(struct fman_mac_params *params)
 	dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
 	if (!dtsec->tbiphy) {
 		pr_err("of_phy_find_device (TBI PHY) failed\n");
-		put_device(&dtsec->tbiphy->mdio.dev);
 		goto err_dtsec_drv_param;
 	}
 
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] fsl/fman: Delete one function call "put_device" in dtsec_config()
@ 2016-01-14 15:00       ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2016-01-14 15:00 UTC (permalink / raw)
  To: Andrew Lunn, Dan Carpenter, David S. Miller, Igal Liberman, netdev
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 15:46:28 +0100

The Coccinelle semantic patch script "deref_null.cocci" pointed a problem
out in the implementation of the function "dtsec_config".

A null pointer was assigned to the data structure member "tbiphy" of the
variable "dtsec" if a matching device was not found.
A call of the function "put_device" was unnecessary then because
a previous call of the function "get_device" was not triggered.
Thus remove the function call "put_device" after the printing of the
desired error message.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/fman/fman_dtsec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 6b1261c..7c92eb8 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -1434,7 +1434,6 @@ struct fman_mac *dtsec_config(struct fman_mac_params *params)
 	dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
 	if (!dtsec->tbiphy) {
 		pr_err("of_phy_find_device (TBI PHY) failed\n");
-		put_device(&dtsec->tbiphy->mdio.dev);
 		goto err_dtsec_drv_param;
 	}
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] fsl/fman: Delete one function call "put_device" in dtsec_config()
  2016-01-14 15:00       ` SF Markus Elfring
@ 2016-01-14 16:27         ` Andrew Lunn
  -1 siblings, 0 replies; 12+ messages in thread
From: Andrew Lunn @ 2016-01-14 16:27 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, David S. Miller, Igal Liberman, netdev,
	linux-kernel, kernel-janitors, Julia Lawall

On Thu, Jan 14, 2016 at 04:00:46PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 14 Jan 2016 15:46:28 +0100
> 
> The Coccinelle semantic patch script "deref_null.cocci" pointed a problem
> out in the implementation of the function "dtsec_config".
> 
> A null pointer was assigned to the data structure member "tbiphy" of the
> variable "dtsec" if a matching device was not found.
> A call of the function "put_device" was unnecessary then because
> a previous call of the function "get_device" was not triggered.
> Thus remove the function call "put_device" after the printing of the
> desired error message.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Fixes: 57ba4c9b56d8 ("fsl/fman: Add FMan MAC support")
Reviewd-by: Andrew Lunn <andrew@lunn.ch>

	    Andrew
> ---
>  drivers/net/ethernet/freescale/fman/fman_dtsec.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> index 6b1261c..7c92eb8 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> @@ -1434,7 +1434,6 @@ struct fman_mac *dtsec_config(struct fman_mac_params *params)
>  	dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
>  	if (!dtsec->tbiphy) {
>  		pr_err("of_phy_find_device (TBI PHY) failed\n");
> -		put_device(&dtsec->tbiphy->mdio.dev);
>  		goto err_dtsec_drv_param;
>  	}
>  
> -- 
> 2.6.3
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] fsl/fman: Delete one function call "put_device" in dtsec_config()
@ 2016-01-14 16:27         ` Andrew Lunn
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Lunn @ 2016-01-14 16:27 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, David S. Miller, Igal Liberman, netdev,
	linux-kernel, kernel-janitors, Julia Lawall

On Thu, Jan 14, 2016 at 04:00:46PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 14 Jan 2016 15:46:28 +0100
> 
> The Coccinelle semantic patch script "deref_null.cocci" pointed a problem
> out in the implementation of the function "dtsec_config".
> 
> A null pointer was assigned to the data structure member "tbiphy" of the
> variable "dtsec" if a matching device was not found.
> A call of the function "put_device" was unnecessary then because
> a previous call of the function "get_device" was not triggered.
> Thus remove the function call "put_device" after the printing of the
> desired error message.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Fixes: 57ba4c9b56d8 ("fsl/fman: Add FMan MAC support")
Reviewd-by: Andrew Lunn <andrew@lunn.ch>

	    Andrew
> ---
>  drivers/net/ethernet/freescale/fman/fman_dtsec.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> index 6b1261c..7c92eb8 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> @@ -1434,7 +1434,6 @@ struct fman_mac *dtsec_config(struct fman_mac_params *params)
>  	dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
>  	if (!dtsec->tbiphy) {
>  		pr_err("of_phy_find_device (TBI PHY) failed\n");
> -		put_device(&dtsec->tbiphy->mdio.dev);
>  		goto err_dtsec_drv_param;
>  	}
>  
> -- 
> 2.6.3
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] fsl/fman: Delete one function call "put_device" in dtsec_config()
  2016-01-14 15:00       ` SF Markus Elfring
@ 2016-01-14 21:51         ` David Miller
  -1 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2016-01-14 21:51 UTC (permalink / raw)
  To: elfring
  Cc: andrew, dan.carpenter, igal.liberman, netdev, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 16:00:46 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 14 Jan 2016 15:46:28 +0100
> 
> The Coccinelle semantic patch script "deref_null.cocci" pointed a problem
> out in the implementation of the function "dtsec_config".
> 
> A null pointer was assigned to the data structure member "tbiphy" of the
> variable "dtsec" if a matching device was not found.
> A call of the function "put_device" was unnecessary then because
> a previous call of the function "get_device" was not triggered.
> Thus remove the function call "put_device" after the printing of the
> desired error message.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] fsl/fman: Delete one function call "put_device" in dtsec_config()
@ 2016-01-14 21:51         ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2016-01-14 21:51 UTC (permalink / raw)
  To: elfring
  Cc: andrew, dan.carpenter, igal.liberman, netdev, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 16:00:46 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 14 Jan 2016 15:46:28 +0100
> 
> The Coccinelle semantic patch script "deref_null.cocci" pointed a problem
> out in the implementation of the function "dtsec_config".
> 
> A null pointer was assigned to the data structure member "tbiphy" of the
> variable "dtsec" if a matching device was not found.
> A call of the function "put_device" was unnecessary then because
> a previous call of the function "get_device" was not triggered.
> Thus remove the function call "put_device" after the printing of the
> desired error message.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-01-14 21:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 21:20 fsl/fman: Clarification for implementation details in dtsec_config() SF Markus Elfring
2016-01-13 21:20 ` SF Markus Elfring
2016-01-13 21:35 ` Dan Carpenter
2016-01-13 21:35   ` Dan Carpenter
2016-01-13 22:09   ` Andrew Lunn
2016-01-13 22:09     ` Andrew Lunn
2016-01-14 15:00     ` [PATCH] fsl/fman: Delete one function call "put_device" " SF Markus Elfring
2016-01-14 15:00       ` SF Markus Elfring
2016-01-14 16:27       ` Andrew Lunn
2016-01-14 16:27         ` Andrew Lunn
2016-01-14 21:51       ` David Miller
2016-01-14 21:51         ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.