public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] firmware: dmi: Check DMI structure length
Date: Thu, 1 Jun 2017 16:40:19 +0200	[thread overview]
Message-ID: <20170601164019.0a4035a4@endymion> (raw)
In-Reply-To: <CAHp75Vf7R_GeFhA5c2PR42K=cp-UbK4u2o7B5N9Ceu_NdFXmzg@mail.gmail.com>

Hi Andy,

Thanks for the review.

On Thu, 1 Jun 2017 16:16:05 +0300, Andy Shevchenko wrote:
> On Thu, Jun 1, 2017 at 4:08 PM, Jean Delvare <jdelvare@suse.de> wrote:
> > Before accessing DMI data to record it for later, we should ensure
> > that the DMI structures are large enough to contain the data in
> > question.  
> 
> > -       const u8 *d = (u8 *) dm + index;
> > +       const u8 *d;  
> 
> > +       d = (u8 *) dm + index;  
> 
> I think you may leave this as is and make it compiler's burden to optimize.

Is there any benefit except making the patch smaller?

> > -       const u8 *d = (u8 *) dm + index;
> > +       const u8 *d;  
> 
> > +       d = (u8 *) dm + index;  
> 
> Ditto.
> 
> > -       int i, count = *(u8 *)(dm + 1);
> > +       int i, count;  
> 
> > +       count = *(u8 *)(dm + 1);  
> 
> Ditto.

I would expect a static code analyzer to complain about at least the
last one. Dereferencing a pointer before checking its validity is bad.

I'm not a big fan of counting of compiler optimizations to make the
code right.

-- 
Jean Delvare
SUSE L3 Support

  reply	other threads:[~2017-06-01 14:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01 13:08 [PATCH] firmware: dmi: Check DMI structure length Jean Delvare
2017-06-01 13:16 ` Andy Shevchenko
2017-06-01 14:40   ` Jean Delvare [this message]
2017-06-01 16:06     ` Andy Shevchenko
2017-06-02 18:40       ` Jean Delvare
2017-06-02 18:45         ` Andy Shevchenko
2017-06-03 21:14           ` Jean Delvare
2017-06-01 14:00 ` Mika Westerberg

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=20170601164019.0a4035a4@endymion \
    --to=jdelvare@suse.de \
    --cc=andy.shevchenko@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /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