summaryrefslogtreecommitdiff
path: root/drivers/net/can/janz-ican3.c
diff options
context:
space:
mode:
authorOliver Hartkopp <socketcan@hartkopp.net>2014-01-30 09:11:28 (GMT)
committerJiri Slaby <jslaby@suse.cz>2014-02-26 09:22:51 (GMT)
commitb3097b176d15f0342cd3ca5c25bb03f06123ecd7 (patch)
treeb9ed06a895f4835fcec08a38bb701f1f2c4b2376 /drivers/net/can/janz-ican3.c
parentd7691e10f65fd732695f1ccc60b89b712ad0bb49 (diff)
downloadlinux-fsl-qoriq-b3097b176d15f0342cd3ca5c25bb03f06123ecd7.tar.xz
can: add destructor for self generated skbs
[ Upstream commit 0ae89beb283a0db5980d1d4781c7d7be2f2810d6 ] Self generated skbuffs in net/can/bcm.c are setting a skb->sk reference but no explicit destructor which is enforced since Linux 3.11 with commit 376c7311bdb6 (net: add a temporary sanity check in skb_orphan()). This patch adds some helper functions to make sure that a destructor is properly defined when a sock reference is assigned to a CAN related skb. To create an unshared skb owned by the original sock a common helper function has been introduced to replace open coded functions to create CAN echo skbs. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Tested-by: Andre Naujoks <nautsch2@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'drivers/net/can/janz-ican3.c')
-rw-r--r--drivers/net/can/janz-ican3.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index 36bd6fa..db2ff03 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -19,6 +19,7 @@
#include <linux/netdevice.h>
#include <linux/can.h>
#include <linux/can/dev.h>
+#include <linux/can/skb.h>
#include <linux/can/error.h>
#include <linux/mfd/janz.h>
@@ -1134,20 +1135,9 @@ static void ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg)
*/
static void ican3_put_echo_skb(struct ican3_dev *mod, struct sk_buff *skb)
{
- struct sock *srcsk = skb->sk;
-
- if (atomic_read(&skb->users) != 1) {
- struct sk_buff *old_skb = skb;
-
- skb = skb_clone(old_skb, GFP_ATOMIC);
- kfree_skb(old_skb);
- if (!skb)
- return;
- } else {
- skb_orphan(skb);
- }
-
- skb->sk = srcsk;
+ skb = can_create_echo_skb(skb);
+ if (!skb)
+ return;
/* save this skb for tx interrupt echo handling */
skb_queue_tail(&mod->echoq, skb);