lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Yu0i9DzLg0kt5Sd9@ziepe.ca>
Date:   Fri, 5 Aug 2022 11:02:28 -0300
From:   Jason Gunthorpe <jgg@...pe.ca>
To:     Bo Liu <liubo03@...pur.com>
Cc:     bvanassche@....org, leon@...nel.org, linux-rdma@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] RDMA/srp: Check dev_set_name() return value

On Fri, Aug 05, 2022 at 01:34:34AM -0400, Bo Liu wrote:
> It's possible that dev_set_name() returns -ENOMEM, catch and handle this.
> 
> Signed-off-by: Bo Liu <liubo03@...pur.com>
> ---
>  drivers/infiniband/ulp/srp/ib_srp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Ah, while you are here can you fix this:

>  	if (device_register(&host->dev))
>  		goto free_host;
[..]
> free_host:
>         kfree(host);

That isn't allowed, you have to do put_device():

/**
 * device_register - register a device with the system.
 * @dev: pointer to the device structure
 *
 * This happens in two clean steps - initialize the device
 * and add it to the system. The two steps can be called
 * separately, but this is the easiest and most common.
 * I.e. you should only call the two helpers separately if
 * have a clearly defined need to use and refcount the device
 * before it is added to the hierarchy.
 *
 * For more information, see the kerneldoc for device_initialize()
 * and device_add().
 *
 * NOTE: _Never_ directly free @dev after calling this function, even
 * if it returned an error! Always use put_device() to give up the
 * reference initialized in this function instead.
 */
int device_register(struct device *dev)

Everyone get this wrong, it is why I think device_register is a
terrible interface. Write it as device_initialize()/device_add() as
seperate steps and never call kfree().

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ