]> bbs.cooldavid.org Git - net-next-2.6.git/commit
firewire: sbp2: fix memory leak in sbp2_cancel_orbs or at send error
authorStefan Richter <stefanr@s5r6.in-berlin.de>
Mon, 16 Aug 2010 19:58:03 +0000 (21:58 +0200)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Thu, 19 Aug 2010 18:28:25 +0000 (20:28 +0200)
commit6c74340bce253ea95c9ee801b3c411a333937edf
tree4be487165cfc295cba5613094430248f6fb968e9
parent840fe6359c1db978d01fceb8a023f5f6efdf7f1c
firewire: sbp2: fix memory leak in sbp2_cancel_orbs or at send error

When an ORB was canceled (Command ORB i.e. SCSI request timed out, or
Management ORB timed out), or there was a send error in the initial
transaction, we missed to drop one of the ORB's references and thus
leaked memory.

Background:
In total, we hold 3 references to each Operation Request Block:
  - 1 during sbp2_scsi_queuecommand() or sbp2_send_management_orb()
    respectively,
  - 1 for the duration of the write transaction to the ORB_Pointer or
    Management_Agent register of the target,
  - 1 for as long as the ORB stays within the lu->orb_list, until
    the ORB is unlinked from the list and the orb->callback was
    executed.

The latter one of these 3 references is finished
  - normally by sbp2_status_write() when the target wrote status
    for a pending ORB,
  - or by sbp2_cancel_orbs() in case of an ORB time-out,
  - or by complete_transaction() in case of a send error.
Of them, the latter two lacked the kref_put.

Add the missing kref_put()s.  Add comments to the gets and puts of
references for transaction callbacks and ORB callbacks so that it is
easier to see what is supposed to happen.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
drivers/firewire/sbp2.c