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: <ZteZiKKsAYmGdu0s@surfacebook.localdomain>
Date: Wed, 4 Sep 2024 02:19:36 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: zhangjiao2 <zhangjiao2@...s.chinamobile.com>
Cc: wbg@...nel.org, linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tools/counter: close fd when exit

Tue, Sep 03, 2024 at 04:01:21PM +0800, zhangjiao2 kirjoitti:
> From: zhang jiao <zhangjiao2@...s.chinamobile.com>
> 
> close fd when exit the program

Please, mind English grammar and punctuation.
Also this doesn't state what the problem is.

...

>  		if (ret == -1) {
>  			fprintf(stderr, "Error adding watches[%d]: %s\n", i,
>  				strerror(errno));
> +			close(fd);

Since fd is not used in the messaging it's better to close it before printing
anything. Ditto for other cases.

...

>  		if (ret != sizeof(event_data)) {
>  			fprintf(stderr, "Failed to read event data\n");
> +			close(fd);

>  			return -EIO;

Side note: This will return garbage to the userspace. Should be

			return EIO;

>  		}

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ