[PATCH 1/1] bfa: Fix for possible null pointer dereference

2013-05-26 Thread Jakob Normark
Fix for cppcheck error in bfa_fcs_lport.c

Kernel version: v3.10-rc2

Signed-off-by: Jakob Normark 
---
 drivers/scsi/bfa/bfa_fcs_lport.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index 1224d04..a37c45a 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -5615,13 +5615,14 @@ bfa_fcs_lport_get_rport_max_speed(bfa_fcs_lport_t *port)
bfa_port_speed_t max_speed = 0;
struct bfa_port_attr_s port_attr;
bfa_port_speed_t port_speed, rport_speed;
-   bfa_boolean_t trl_enabled = bfa_fcport_is_ratelim(port->fcs->bfa);
+   bfa_boolean_t trl_enabled;
 
 
if (port == NULL)
return 0;
 
fcs = port->fcs;
+   trl_enabled = bfa_fcport_is_ratelim(port->fcs->bfa);
 
/* Get Physical port's current speed */
bfa_fcport_get_attr(port->fcs->bfa, &port_attr);
-- 
1.7.9.5

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


[PATCH 1/1] bfa: Fixes for 0-terminated strncpy and possible null pointer dereference

2013-05-15 Thread Jakob Normark
This patch fixes two cppcheck errors in drivers/scsi/bfa/bfad_im.c
Kernel version: v3.10-rc1

Signed-off-by: Jakob Normark 
---
 drivers/scsi/bfa/bfad_im.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 5864f98..9489c56 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -944,13 +944,15 @@ static int
 bfad_im_slave_alloc(struct scsi_device *sdev)
 {
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
-   struct bfad_itnim_data_s *itnim_data =
-   (struct bfad_itnim_data_s *) rport->dd_data;
-   struct bfa_s *bfa = itnim_data->itnim->bfa_itnim->bfa;
+   struct bfad_itnim_data_s *itnim_data;
+   struct bfa_s *bfa;
 
if (!rport || fc_remote_port_chkready(rport))
return -ENXIO;
 
+   itnim_data = (struct bfad_itnim_data_s *) rport->dd_data;
+   bfa = itnim_data->itnim->bfa_itnim->bfa;
+
if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_ENABLED) {
/*
 * We should not mask LUN 0 - since this will translate
@@ -1037,6 +1039,7 @@ bfad_fc_host_init(struct bfad_im_port_s *im_port)
 
strncpy(symname, bfad->bfa_fcs.fabric.bport.port_cfg.sym_name.symname,
BFA_SYMNAME_MAXLEN);
+   symname[BFA_SYMNAME_MAXLEN - 1] = '\0';
sprintf(fc_host_symbolic_name(host), "%s", symname);
 
fc_host_supported_speeds(host) = bfad_im_supported_speeds(&bfad->bfa);
-- 
1.7.9.5

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