Skip to content

Commit

Permalink
IB/srp: Avoid using uninitialized variable
Browse files Browse the repository at this point in the history
We might return res which is not initialized. Also
reduce code duplication by exporting srp_parse_tmo so
srp_tmo_set can reuse it.

Detected by Coverity.

Signed-off-by: Sagi Grimberg <[email protected]>
Signed-off-by: Jenny Falkovich <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
Sagi Grimberg authored and dledford committed Jul 14, 2015
1 parent b356c1c commit 3fdf70a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 4 additions & 7 deletions drivers/infiniband/ulp/srp/ib_srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,10 @@ static int srp_tmo_set(const char *val, const struct kernel_param *kp)
{
int tmo, res;

if (strncmp(val, "off", 3) != 0) {
res = kstrtoint(val, 0, &tmo);
if (res)
goto out;
} else {
tmo = -1;
}
res = srp_parse_tmo(&tmo, val);
if (res)
goto out;

if (kp->arg == &srp_reconnect_delay)
res = srp_tmo_valid(tmo, srp_fast_io_fail_tmo,
srp_dev_loss_tmo);
Expand Down
3 changes: 2 additions & 1 deletion drivers/scsi/scsi_transport_srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static ssize_t srp_show_tmo(char *buf, int tmo)
return tmo >= 0 ? sprintf(buf, "%d\n", tmo) : sprintf(buf, "off\n");
}

static int srp_parse_tmo(int *tmo, const char *buf)
int srp_parse_tmo(int *tmo, const char *buf)
{
int res = 0;

Expand All @@ -214,6 +214,7 @@ static int srp_parse_tmo(int *tmo, const char *buf)

return res;
}
EXPORT_SYMBOL(srp_parse_tmo);

static ssize_t show_reconnect_delay(struct device *dev,
struct device_attribute *attr, char *buf)
Expand Down
1 change: 1 addition & 0 deletions include/scsi/scsi_transport_srp.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ extern struct srp_rport *srp_rport_add(struct Scsi_Host *,
extern void srp_rport_del(struct srp_rport *);
extern int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo,
int dev_loss_tmo);
int srp_parse_tmo(int *tmo, const char *buf);
extern int srp_reconnect_rport(struct srp_rport *rport);
extern void srp_start_tl_fail_timers(struct srp_rport *rport);
extern void srp_remove_host(struct Scsi_Host *);
Expand Down

0 comments on commit 3fdf70a

Please sign in to comment.