diff mbox

[1/2] IB/srp: Always initialize use_fast_reg and use_fmr

Message ID 4b1522b5-31a2-9c7e-6b20-4e859c009345@sandisk.com (mailing list archive)
State Accepted
Headers show

Commit Message

Bart Van Assche June 3, 2016, 6:39 p.m. UTC
Avoid that mapping fails due to use_fast_reg != 0 or use_fmr != 0
if both member variables should be zero (if never_register == 1 or
if neither FMR nor FR is supported). Remove an initialization that
became superfluous due to changing a kmalloc() into a kzalloc()
call.

Fixes: 509c5f33f4f6 ("IB/srp: Prevent mapping failures")
Cc: Sagi Grimberg <sai@grimberg.m>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Leon Romanovsky June 6, 2016, 7:17 a.m. UTC | #1
On Fri, Jun 03, 2016 at 11:39:35AM -0700, Bart Van Assche wrote:
> Avoid that mapping fails due to use_fast_reg != 0 or use_fmr != 0
> if both member variables should be zero (if never_register == 1 or
> if neither FMR nor FR is supported). Remove an initialization that
> became superfluous due to changing a kmalloc() into a kzalloc()
> call.
> 
> Fixes: 509c5f33f4f6 ("IB/srp: Prevent mapping failures")
> Cc: Sagi Grimberg <sai@grimberg.m>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Laurence Oberman <loberman@redhat.com>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>

Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Sagi Grimberg June 6, 2016, 11:08 a.m. UTC | #2
Looks fine,

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoph Hellwig June 6, 2016, 5:33 p.m. UTC | #3
Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 646de17..bc24b8d 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -3526,7 +3526,7 @@  static void srp_add_one(struct ib_device *device)
 	int mr_page_shift, p;
 	u64 max_pages_per_mr;
 
-	srp_dev = kmalloc(sizeof *srp_dev, GFP_KERNEL);
+	srp_dev = kzalloc(sizeof(*srp_dev), GFP_KERNEL);
 	if (!srp_dev)
 		return;
 
@@ -3586,8 +3586,6 @@  static void srp_add_one(struct ib_device *device)
 						   IB_ACCESS_REMOTE_WRITE);
 		if (IS_ERR(srp_dev->global_mr))
 			goto err_pd;
-	} else {
-		srp_dev->global_mr = NULL;
 	}
 
 	for (p = rdma_start_port(device); p <= rdma_end_port(device); ++p) {