On 5/23/23 17:29, Jinpu Wang wrote:
On Tue, May 23, 2023 at 9:53 AM Guoqing Jiang <guoqing.jiang@xxxxxxxxx> wrote:
Only allocate priv after session is available.
Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxx>
---
drivers/block/rnbd/rnbd-srv.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c
index c4122e65b36a..b4c880759a52 100644
--- a/drivers/block/rnbd/rnbd-srv.c
+++ b/drivers/block/rnbd/rnbd-srv.c
@@ -128,20 +128,17 @@ static int process_rdma(struct rnbd_srv_session *srv_sess,
trace_process_rdma(srv_sess, msg, id, datalen, usrlen);
- priv = kmalloc(sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
-
dev_id = le32_to_cpu(msg->device_id);
-
sess_dev = rnbd_get_sess_dev(dev_id, srv_sess);
if (IS_ERR(sess_dev)) {
pr_err_ratelimited("Got I/O request on session %s for unknown device id %d\n",
srv_sess->sessname, dev_id);
- err = -ENOTCONN;
- goto err;
+ return -ENOTCONN;
}
+ priv = kmalloc(sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
before return you have to rnbd_put_sess_dev!
it seems not much benefit with the change.
You are right, thanks for the review.
Guoqing