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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230110182607.3a41ab85@kernel.org>
Date:   Tue, 10 Jan 2023 18:26:07 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     Tony Nguyen <anthony.l.nguyen@...el.com>
Cc:     davem@...emloft.net, pabeni@...hat.com, edumazet@...gle.com,
        Jiasheng Jiang <jiasheng@...as.ac.cn>, netdev@...r.kernel.org,
        Jiri Pirko <jiri@...dia.com>,
        Gurucharan G <gurucharanx.g@...el.com>
Subject: Re: [PATCH net 2/2] ice: Add check for kzalloc

On Mon,  9 Jan 2023 14:53:58 -0800 Tony Nguyen wrote:
> @@ -470,21 +473,23 @@ static struct tty_driver *ice_gnss_create_tty_driver(struct ice_pf *pf)
>  	err = tty_register_driver(tty_driver);
>  	if (err) {
>  		dev_err(dev, "Failed to register TTY driver err=%d\n", err);
> -
> -		for (i = 0; i < ICE_GNSS_TTY_MINOR_DEVICES; i++) {
> -			tty_port_destroy(pf->gnss_tty_port[i]);
> -			kfree(pf->gnss_tty_port[i]);
> -		}
> -		kfree(ttydrv_name);
> -		tty_driver_kref_put(pf->ice_gnss_tty_driver);
> -
> -		return NULL;
> +		goto err_out;

FTR I think that depending on i == ICE_GNSS_TTY_MINOR_DEVICES
here is fragile. I can merge as is, since the code is technically
correct, but what you should have done is crate a new label, say
err_unreg_all_ports, do:

	goto err_unreg_all_ports;

>  	}
>  
>  	for (i = 0; i < ICE_GNSS_TTY_MINOR_DEVICES; i++)
>  		dev_info(dev, "%s%d registered\n", ttydrv_name, i);
>  
>  	return tty_driver;
> +

And here add:

err_unreg_all_ports:
	i = ICE_GNSS_TTY_MINOR_DEVICES;
> +err_out:
> +	while (i--) {
> +		tty_port_destroy(pf->gnss_tty_port[i]);
> +		kfree(pf->gnss_tty_port[i]);
> +	}
> +	kfree(ttydrv_name);
> +	tty_driver_kref_put(pf->ice_gnss_tty_driver);
> +
> +	return NULL;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ