diff mbox

[resend,v2,SCSI] bfa: fix bfa_fcb_itnim_alloc() error handling

Message ID 20160413111441.GC4247@mwanda (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Dan Carpenter April 13, 2016, 11:14 a.m. UTC
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>
---
v2: fix up the subject and CC list.

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Martin K. Petersen May 6, 2016, 1:23 a.m. UTC | #1
>>>>> "Dan" == Dan Carpenter <dan.carpenter@oracle.com> writes:

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

Anil, please review:

	https://patchwork.kernel.org/patch/8820751/
Anil Gurumurthy May 6, 2016, 6:44 a.m. UTC | #2
Apologies for the delay. Patch looks good.

Acked by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>


-----Original Message-----
From: Martin K. Petersen [mailto:martin.petersen@oracle.com] 
Sent: 06 May 2016 06:54
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Anil Gurumurthy <Anil.Gurumurthy@qlogic.com>; Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>; James E.J. Bottomley <jejb@linux.vnet.ibm.com>; Martin K. Petersen <martin.petersen@oracle.com>; linux-scsi <linux-scsi@vger.kernel.org>; kernel-janitors@vger.kernel.org
Subject: Re: [PATCH resend v2] [SCSI] bfa: fix bfa_fcb_itnim_alloc() error handling

>>>>> "Dan" == Dan Carpenter <dan.carpenter@oracle.com> writes:

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

Anil, please review:

	https://patchwork.kernel.org/patch/8820751/
Martin K. Petersen May 10, 2016, 2:19 a.m. UTC | #3
>>>>> "Anil" == Anil Gurumurthy <Anil.Gurumurthy@qlogic.com> writes:

Anil> Apologies for the delay. Patch looks good.  Acked by: Anil
Anil> Gurumurthy <anil.gurumurthy@qlogic.com>

Applied to 4.7/scsi-queue.
diff mbox

Patch

diff --git a/drivers/scsi/bfa/bfa_fcs.h b/drivers/scsi/bfa/bfa_fcs.h
index 42bcb97..af220e9 100644
--- a/drivers/scsi/bfa/bfa_fcs.h
+++ b/drivers/scsi/bfa/bfa_fcs.h
@@ -873,8 +873,8 @@  bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
 /*
  * itnim callbacks
  */
-void bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
-			 struct bfad_itnim_s **itnim_drv);
+int bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
+			struct bfad_itnim_s **itnim_drv);
 void bfa_fcb_itnim_free(struct bfad_s *bfad,
 			struct bfad_itnim_s *itnim_drv);
 void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 7223b00..31426ae 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -413,13 +413,13 @@  bfad_im_slave_destroy(struct scsi_device *sdev)
  * BFA FCS itnim alloc callback, after successful PRLI
  * Context: Interrupt
  */
-void
+int
 bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
 		    struct bfad_itnim_s **itnim_drv)
 {
 	*itnim_drv = kzalloc(sizeof(struct bfad_itnim_s), GFP_ATOMIC);
 	if (*itnim_drv == NULL)
-		return;
+		return -ENOMEM;
 
 	(*itnim_drv)->im = bfad->im;
 	*itnim = &(*itnim_drv)->fcs_itnim;
@@ -430,6 +430,7 @@  bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
 	 */
 	INIT_WORK(&(*itnim_drv)->itnim_work, bfad_im_itnim_work_handler);
 	bfad->bfad_flags |= BFAD_RPORT_ONLINE;
+	return 0;
 }
 
 /*
diff --git a/drivers/scsi/bfa/bfa_fcs_fcpim.c b/drivers/scsi/bfa/bfa_fcs_fcpim.c
index 6dc7926..829247e 100644
--- a/drivers/scsi/bfa/bfa_fcs_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcs_fcpim.c
@@ -587,12 +587,13 @@  bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport)
 	struct bfa_fcs_lport_s *port = rport->port;
 	struct bfa_fcs_itnim_s *itnim;
 	struct bfad_itnim_s   *itnim_drv;
+	int ret;
 
 	/*
 	 * call bfad to allocate the itnim
 	 */
-	bfa_fcb_itnim_alloc(port->fcs->bfad, &itnim, &itnim_drv);
-	if (itnim == NULL) {
+	ret = bfa_fcb_itnim_alloc(port->fcs->bfad, &itnim, &itnim_drv);
+	if (ret) {
 		bfa_trc(port->fcs, rport->pwwn);
 		return NULL;
 	}