From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Colin Ian King <colin.king@canonical.com>
Cc: James Hogan <james.hogan@imgtec.com>,
Jiri Slaby <jslaby@suse.com>,
linux-metag@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty/metag_da: initialize number_written to zero
Date: Sat, 6 Feb 2016 23:41:09 -0800 [thread overview]
Message-ID: <20160207074109.GA6508@kroah.com> (raw)
In-Reply-To: <56AA6271.1070108@canonical.com>
On Thu, Jan 28, 2016 at 06:48:17PM +0000, Colin Ian King wrote:
> On 27/01/16 11:42, James Hogan wrote:
> > Hi Colin,
> >
> > On Tue, Jan 26, 2016 at 11:37:25PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> number_written is not initialized, so it can be any value. In the
> >> case where dport->xmit_cnt is zero, number_written is not set
> >> and subsequent accesses to it will be reading a garbage value.
> >
> > the only subsequent accesses when dport->xmit_cnt == 0 are:
> >
> > /* if we've made more data available, wake up tty */
> > if (count && number_written) {
> >
> > and:
> >
> > /* did the write fail? */
> > return count && !number_written;
> >
> > but dport->xmit_cnt == 0 implies count == 0, so number_written shouldn
> 't
> > be used, and both will evaluate to false regardless of the uninitialis
> ed
> > value, so it looks fine as it is to me.
> >
> > Is this tripping up some static analysis tool or something?
>
> It was found using cppcheck, namely:
>
> [drivers/tty/metag_da.c:269]: (error) Uninitialized variable: number_wri
> tten
Please fix the broken tool, don't paper over it by doing unnecessary
work in the kernel.
thanks,
greg k-h
next prev parent reply other threads:[~2016-02-07 7:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 23:37 [PATCH] tty/metag_da: initialize number_written to zero Colin King
[not found] ` <1453851445-4645-1-git-send-email-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2016-01-27 11:42 ` James Hogan
2016-01-28 18:48 ` Colin Ian King
2016-02-07 7:41 ` Greg Kroah-Hartman [this message]
[not found] ` <20160207074109.GA6508-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2016-02-07 7:59 ` Colin Ian King
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=20160207074109.GA6508@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=colin.king@canonical.com \
--cc=james.hogan@imgtec.com \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-metag@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