lkml.org 
[lkml]   [2020]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] RDMA/core: Complete exception handling in add_port()
From
Date
> In function add_port(), pointer p is not released in error paths.

1. I would prefer to describe that an ib_port data structure was not released
in some error cases.
How relevant can its size be here?


> Fix this issue by adding a kfree(p) into the end of error path.

2. I suggest to improve also this change description.

3. I find an other subject more appropriate.



> +++ b/drivers/infiniband/core/sysfs.c
> @@ -1202,6 +1202,7 @@ static int add_port(struct ib_core_device *coredev, int port_num)
>
> err_put:
> kobject_put(&p->kobj);
> + kfree(p);
> return ret;
> }

4. I recommend to add also the label “free_port” before the missed function call.

Another source code place should be accordingly adjusted then.

ret = kobject_init_and_add(&p->kobj, &port_type,
coredev->ports_kobj,
"%d", port_num);
- if (ret) {
- kfree(p);
- return ret;
- }
+ if (ret)
+ goto free_port;


5. Will a similar adjustment be needed for the data structure member “gid_attr_group”
according to the desired complete exception handling?

Regards,
Markus

\
 
 \ /
  Last update: 2020-05-25 14:56    [W:0.123 / U:0.696 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site