]> git.karo-electronics.de Git - karo-tx-linux.git/commit
drivers/scsi/aacraid/commctrl.c: fix mem leak in aac_send_raw_srb()
authorJesper Juhl <jj@chaosbits.net>
Mon, 24 Oct 2011 14:53:48 +0000 (01:53 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 25 Oct 2011 09:01:49 +0000 (20:01 +1100)
commit8f1dd13905c57f112c938e522adab38d79ecadb0
tree4192be4cda96f6f608deaf4a26f0f2a2e6289c1d
parent6bd165123885d454d6d64189168884d75e89ae24
drivers/scsi/aacraid/commctrl.c: fix mem leak in aac_send_raw_srb()

We leak in drivers/scsi/aacraid/commctrl.c::aac_send_raw_srb() :

We allocate memory:
        ...
                        struct user_sgmap* usg;
                        usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
                          + sizeof(struct sgmap), GFP_KERNEL);
and then neglect to free it:
        ...
                        for (i = 0; i < usg->count; i++) {
                                u64 addr;
                                void* p;
                                if (usg->sg[i].count >
                                    ((dev->adapter_info.options &
                                     AAC_OPT_NEW_COMM) ?
                                      (dev->scsi_host_ptr->max_sectors << 9) :
                                      65536)) {
                                        rcode = -EINVAL;
                                        goto cleanup;
        ... this 'goto' makes 'usg' go out of scope and leak the memory we
            allocated.
            Other exits properly kfree(usg), it's just here it is neglected.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/scsi/aacraid/commctrl.c