Skip to content

Commit

Permalink
firewire: net: fix use after free
Browse files Browse the repository at this point in the history
Commit 8408dc1 "firewire: net: use dev_printk API" introduced a
use-after-free in a failure path.  fwnet_transmit_packet_failed(ptask)
may free ptask, then the dev_err() call dereferenced it.  The fix is
straightforward; simply reorder the two calls.

Reported-by: Dan Carpenter <[email protected]>
Cc: [email protected] # v3.4+
Signed-off-by: Stefan Richter <[email protected]>
  • Loading branch information
Stefan Richter committed Feb 28, 2014
1 parent cfbf8d4 commit 8987583
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/firewire/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,17 +929,17 @@ static void fwnet_write_complete(struct fw_card *card, int rcode,
if (rcode == RCODE_COMPLETE) {
fwnet_transmit_packet_done(ptask);
} else {
fwnet_transmit_packet_failed(ptask);

if (printk_timed_ratelimit(&j, 1000) || rcode != last_rcode) {
dev_err(&ptask->dev->netdev->dev,
"fwnet_write_complete failed: %x (skipped %d)\n",
rcode, errors_skipped);

errors_skipped = 0;
last_rcode = rcode;
} else
} else {
errors_skipped++;
}
fwnet_transmit_packet_failed(ptask);
}
}

Expand Down

0 comments on commit 8987583

Please sign in to comment.