Re: [PATCH 05/10] block/rnbd-srv: defer the allocation of rnbd_io_private

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
>         priv->sess_dev = sess_dev;
>         priv->id = id;
>
> @@ -169,7 +166,6 @@ static int process_rdma(struct rnbd_srv_session *srv_sess,
>  bio_put:
>         bio_put(bio);
>         rnbd_put_sess_dev(sess_dev);
> -err:
>         kfree(priv);
>         return err;
>  }
> --
> 2.35.3
>




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux