Patchwork ibm_newemac: Fix dangerous struct assumption

login
register
mail settings
Submitter Jean Delvare
Date April 6, 2009, 12:27 p.m.
Message ID <20090406142710.2d091038@hyperion.delvare>
Download mbox | patch
Permalink /patch/25633/
State Accepted
Delegated to: David Miller
Headers show

Comments

Jean Delvare - April 6, 2009, 12:27 p.m.
The ibm_newemac driver includes code which assumes that the
work_struct which is included in every delayed_work is the first
member of that structure. This is currently the case but might change
in the future, so use to_delayed_work() instead, which doesn't make
such an assumption.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Josh Boyer <jwboyer@linux.vnet.ibm.com>
---
 drivers/net/ibm_newemac/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
David Miller - April 7, 2009, 12:43 a.m.
From: Jean Delvare <khali@linux-fr.org>
Date: Mon, 6 Apr 2009 14:27:10 +0200

> The ibm_newemac driver includes code which assumes that the
> work_struct which is included in every delayed_work is the first
> member of that structure. This is currently the case but might change
> in the future, so use to_delayed_work() instead, which doesn't make
> such an assumption.
> 
> Signed-off-by: Jean Delvare <khali@linux-fr.org>

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

Patch

--- linux-2.6.30-rc0.orig/drivers/net/ibm_newemac/core.c	2009-04-06 11:18:25.000000000 +0200
+++ linux-2.6.30-rc0/drivers/net/ibm_newemac/core.c	2009-04-06 13:29:29.000000000 +0200
@@ -1229,7 +1229,7 @@  static int emac_link_differs(struct emac
 static void emac_link_timer(struct work_struct *work)
 {
 	struct emac_instance *dev =
-		container_of((struct delayed_work *)work,
+		container_of(to_delayed_work(work),
 			     struct emac_instance, link_work);
 	int link_poll_interval;