* Re: [PATCH] RDMA/core: Complete exception handling in add_port()
@ 2020-05-25 12:54 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2020-05-25 12:54 UTC (permalink / raw)
To: Qiushi Wu, linux-rdma
Cc: kernel-janitors, linux-kernel, Doug Ledford, Jason Gunthorpe,
Kangjie Lu, Leon Romanovsky
> 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-25 12:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 12:54 [PATCH] RDMA/core: Complete exception handling in add_port() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).