Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bfa: fix bfa_fcb_itnim_alloc() error handling

The caller assumes that "itnim" is NULL on error and non-NULL on success
but really "itnim" is uninitialized on error. This function should just
use normal error handling where it returns zero on success and negative
on failure.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Dan Carpenter and committed by
Martin K. Petersen
4e51af9e 13f30771

+8 -6
+2 -2
drivers/scsi/bfa/bfa_fcs.h
··· 874 874 /* 875 875 * itnim callbacks 876 876 */ 877 - void bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim, 878 - struct bfad_itnim_s **itnim_drv); 877 + int bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim, 878 + struct bfad_itnim_s **itnim_drv); 879 879 void bfa_fcb_itnim_free(struct bfad_s *bfad, 880 880 struct bfad_itnim_s *itnim_drv); 881 881 void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
+3 -2
drivers/scsi/bfa/bfa_fcs_fcpim.c
··· 588 588 struct bfa_fcs_lport_s *port = rport->port; 589 589 struct bfa_fcs_itnim_s *itnim; 590 590 struct bfad_itnim_s *itnim_drv; 591 + int ret; 591 592 592 593 /* 593 594 * call bfad to allocate the itnim 594 595 */ 595 - bfa_fcb_itnim_alloc(port->fcs->bfad, &itnim, &itnim_drv); 596 - if (itnim == NULL) { 596 + ret = bfa_fcb_itnim_alloc(port->fcs->bfad, &itnim, &itnim_drv); 597 + if (ret) { 597 598 bfa_trc(port->fcs, rport->pwwn); 598 599 return NULL; 599 600 }
+3 -2
drivers/scsi/bfa/bfad_im.c
··· 440 440 * BFA FCS itnim alloc callback, after successful PRLI 441 441 * Context: Interrupt 442 442 */ 443 - void 443 + int 444 444 bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim, 445 445 struct bfad_itnim_s **itnim_drv) 446 446 { 447 447 *itnim_drv = kzalloc(sizeof(struct bfad_itnim_s), GFP_ATOMIC); 448 448 if (*itnim_drv == NULL) 449 - return; 449 + return -ENOMEM; 450 450 451 451 (*itnim_drv)->im = bfad->im; 452 452 *itnim = &(*itnim_drv)->fcs_itnim; ··· 457 457 */ 458 458 INIT_WORK(&(*itnim_drv)->itnim_work, bfad_im_itnim_work_handler); 459 459 bfad->bfad_flags |= BFAD_RPORT_ONLINE; 460 + return 0; 460 461 } 461 462 462 463 /*