From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH] login: remove file descriptor leak [cppcheck]
Date: Wed, 20 Feb 2013 21:31:09 +0000 [thread overview]
Message-ID: <1361395869-2959-1-git-send-email-kerolasa@iki.fi> (raw)
[login-utils/login.c:510]: (error) Resource leak: fd
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
login-utils/login.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/login-utils/login.c b/login-utils/login.c
index a17083b..4250534 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -506,8 +506,10 @@ static void log_lastlog(struct login_context *cxt)
if (fd < 0)
return;
- if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)
+ if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1) {
+ close(fd);
return;
+ }
/*
* Print last log message
--
1.8.1.4
next reply other threads:[~2013-02-20 21:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-20 21:31 Sami Kerola [this message]
2013-03-04 11:31 ` [PATCH] login: remove file descriptor leak [cppcheck] Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361395869-2959-1-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox