Skip to content

Commit 6bd113f

Browse files
committed
Merge tag 'ib-srpt-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband
Cleanups and error path fixes for the new SRP (SCSI RDMA protocol) target. * tag 'ib-srpt-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband: IB/srpt: Don't return freed pointer from srpt_alloc_ioctx_ring() IB/srpt: Fix ERR_PTR() vs. NULL checking confusion IB/srpt: Remove unneeded <linux/version.h> include IB/srpt: Use ARRAY_SIZE() instead of open-coding IB/srpt: Use DEFINE_SPINLOCK()/LIST_HEAD()
2 parents 95025d6 + 715252d commit 6bd113f

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

drivers/infiniband/ulp/srpt/ib_srpt.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ MODULE_LICENSE("Dual BSD/GPL");
6969
*/
7070

7171
static u64 srpt_service_guid;
72-
static spinlock_t srpt_dev_lock; /* Protects srpt_dev_list. */
73-
static struct list_head srpt_dev_list; /* List of srpt_device structures. */
72+
static DEFINE_SPINLOCK(srpt_dev_lock); /* Protects srpt_dev_list. */
73+
static LIST_HEAD(srpt_dev_list); /* List of srpt_device structures. */
7474

7575
static unsigned srp_max_req_size = DEFAULT_MAX_REQ_SIZE;
7676
module_param(srp_max_req_size, int, 0444);
@@ -687,6 +687,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
687687
while (--i >= 0)
688688
srpt_free_ioctx(sdev, ring[i], dma_size, dir);
689689
kfree(ring);
690+
ring = NULL;
690691
out:
691692
return ring;
692693
}
@@ -2595,7 +2596,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
25952596
}
25962597

25972598
ch->sess = transport_init_session();
2598-
if (!ch->sess) {
2599+
if (IS_ERR(ch->sess)) {
25992600
rej->reason = __constant_cpu_to_be32(
26002601
SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
26012602
pr_debug("Failed to create session\n");
@@ -3264,8 +3265,7 @@ static void srpt_add_one(struct ib_device *device)
32643265
for (i = 0; i < sdev->srq_size; ++i)
32653266
srpt_post_recv(sdev, sdev->ioctx_ring[i]);
32663267

3267-
WARN_ON(sdev->device->phys_port_cnt
3268-
> sizeof(sdev->port)/sizeof(sdev->port[0]));
3268+
WARN_ON(sdev->device->phys_port_cnt > ARRAY_SIZE(sdev->port));
32693269

32703270
for (i = 1; i <= sdev->device->phys_port_cnt; i++) {
32713271
sport = &sdev->port[i - 1];
@@ -4010,13 +4010,10 @@ static int __init srpt_init_module(void)
40104010
goto out;
40114011
}
40124012

4013-
spin_lock_init(&srpt_dev_lock);
4014-
INIT_LIST_HEAD(&srpt_dev_list);
4015-
4016-
ret = -ENODEV;
40174013
srpt_target = target_fabric_configfs_init(THIS_MODULE, "srpt");
4018-
if (!srpt_target) {
4014+
if (IS_ERR(srpt_target)) {
40194015
printk(KERN_ERR "couldn't register\n");
4016+
ret = PTR_ERR(srpt_target);
40204017
goto out;
40214018
}
40224019

drivers/infiniband/ulp/srpt/ib_srpt.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#ifndef IB_SRPT_H
3636
#define IB_SRPT_H
3737

38-
#include <linux/version.h>
3938
#include <linux/types.h>
4039
#include <linux/list.h>
4140
#include <linux/wait.h>

0 commit comments

Comments
 (0)