Re: [PATCH] Fixed an open function not judging the return value and closed the open function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon,  4 Dec 2023 03:05:54 -0500 liujing <liujing@xxxxxxxxxxxxxxxxxxxx> wrote:

> Signed-off-by: liujing <liujing@xxxxxxxxxxxxxxxxxxxx>
> ---
>  tools/testing/selftests/proc/proc-pid-vm.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
> index cacbd2a4aec9..5fc9b46f236f 100644
> --- a/tools/testing/selftests/proc/proc-pid-vm.c
> +++ b/tools/testing/selftests/proc/proc-pid-vm.c
> @@ -205,7 +205,12 @@ static int make_exe(const uint8_t *payload, size_t len)
>  	/* Avoid ETXTBSY on exec. */
>  	snprintf(buf, sizeof(buf), "/proc/self/fd/%u", fd);
>  	fd1 = open(buf, O_RDONLY|O_CLOEXEC);
> +	if (fd == -1) {

fd1

> +		exit(1);
> +	}

unneeded braces

>  	close(fd);
> +	close(fd1);
>  
>  	return fd1;

Returning an fd which we just closed is clearly wrong.




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux