If 'drv_fcxp = kzalloc(sizeof(struct bfad_fcxp), GFP_KERNEL);' fails
and returns NULL, then we'll leak the memory allocated to 'bsg_fcpt'
when we jump to 'out:' and the variable subsequently goes out of
scope.
Also remove the cast of the kzalloc() return value. kzalloc() returns
a void* which is implicitly converted, so the explicit cast is
pointless.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
         * Allocate buffer for bsg_fcpt and do a copy_from_user op for payload
         * buffer of size bsg_data->payload_len
         */
-       bsg_fcpt = (struct bfa_bsg_fcpt_s *)
-                  kzalloc(bsg_data->payload_len, GFP_KERNEL);
+       bsg_fcpt = kzalloc(bsg_data->payload_len, GFP_KERNEL);
        if (!bsg_fcpt)
                goto out;
 
 
        drv_fcxp = kzalloc(sizeof(struct bfad_fcxp), GFP_KERNEL);
        if (drv_fcxp == NULL) {
+               kfree(bsg_fcpt);
                rc = -ENOMEM;
                goto out;
        }