From patchwork Wed Apr 13 10:59:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 8820611 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F36AA9F3D1 for ; Wed, 13 Apr 2016 11:00:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 203F12014A for ; Wed, 13 Apr 2016 11:00:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23BF820142 for ; Wed, 13 Apr 2016 10:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934261AbcDMK75 (ORCPT ); Wed, 13 Apr 2016 06:59:57 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:18525 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753348AbcDMK74 (ORCPT ); Wed, 13 Apr 2016 06:59:56 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u3DAxpTj003500 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Apr 2016 10:59:52 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u3DAxoqJ015670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 13 Apr 2016 10:59:51 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u3DAxo8H005959; Wed, 13 Apr 2016 10:59:50 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Apr 2016 03:59:49 -0700 Date: Wed, 13 Apr 2016 13:59:46 +0300 From: Dan Carpenter To: Anil Gurumurthy Cc: Sudarsana Kalluru , "James E.J. Bottomley" , linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [SCSI resend] bfa: fix bfa_fcb_itnim_alloc() error handling Message-ID: <20160413105946.GA1895@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Static checker stuff. Not tested. I sent this originally in 2014 but it still seems to apply fine. -- 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 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; }