From: Michael Ellerman <mpe@ellerman.id.au>
To: Kees Cook <keescook@chromium.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
PowerPC <linuxppc-dev@lists.ozlabs.org>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Linux kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers/macintosh/smu.c: Mark expected switch fall-through
Date: Wed, 31 Jul 2019 21:46:34 +1000 [thread overview]
Message-ID: <87ef26qvdx.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <201907301005.0661E63CF@keescook>
Kees Cook <keescook@chromium.org> writes:
> On Wed, Jul 31, 2019 at 12:28:55AM +1000, Michael Ellerman wrote:
>> Stephen Rothwell <sfr@canb.auug.org.au> writes:
>> > Mark switch cases where we are expecting to fall through.
>> >
>> > This patch fixes the following warning (Building: powerpc):
>> >
>> > drivers/macintosh/smu.c: In function 'smu_queue_i2c':
>> > drivers/macintosh/smu.c:854:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
>> > cmd->info.devaddr &= 0xfe;
>> > ~~~~~~~~~~~~~~~~~~^~~~~~~
>> > drivers/macintosh/smu.c:855:2: note: here
>> > case SMU_I2C_TRANSFER_STDSUB:
>> > ^~~~
>> >
>> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> > Cc: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> > Cc: Kees Cook <keescook@chromium.org>
>> > Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
>> > ---
>> > drivers/macintosh/smu.c | 1 +
>> > 1 file changed, 1 insertion(+)
>> >
>> > diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
>> > index 276065c888bc..23f1f41c8602 100644
>> > --- a/drivers/macintosh/smu.c
>> > +++ b/drivers/macintosh/smu.c
>> > @@ -852,6 +852,7 @@ int smu_queue_i2c(struct smu_i2c_cmd *cmd)
>> > break;
>> > case SMU_I2C_TRANSFER_COMBINED:
>> > cmd->info.devaddr &= 0xfe;
>> > + /* fall through */
>> > case SMU_I2C_TRANSFER_STDSUB:
>> > if (cmd->info.sublen > 3)
>> > return -EINVAL;
>>
>> Why do we think it's an expected fall through? I can't really convince
>> myself from the surrounding code that it's definitely intentional.
>
> Yeah, good question. Just now when I went looking for who
> used SMU_I2C_TRANSFER_COMBINED, I found the only caller in
> arch/powerpc/platforms/powermac/low_i2c.c and it is clearly using a
> fall-through for building the command for "stdsub" and "combined",
> so I think that's justification enough:
>
> switch(bus->mode) {
> case pmac_i2c_mode_std:
> if (subsize != 0)
> return -EINVAL;
> cmd->info.type = SMU_I2C_TRANSFER_SIMPLE;
> break;
> case pmac_i2c_mode_stdsub:
> case pmac_i2c_mode_combined:
> if (subsize > 3 || subsize < 1)
> return -EINVAL;
> cmd->info.sublen = subsize;
> /* that's big-endian only but heh ! */
> memcpy(&cmd->info.subaddr, ((char *)&subaddr) + (4 - subsize),
> subsize);
> if (bus->mode == pmac_i2c_mode_stdsub)
> cmd->info.type = SMU_I2C_TRANSFER_STDSUB;
> else
> cmd->info.type = SMU_I2C_TRANSFER_COMBINED;
>
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
Thanks.
cheers
next prev parent reply other threads:[~2019-07-31 11:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 4:37 Stephen Rothwell
2019-07-30 4:45 ` Stephen Rothwell
2019-07-30 14:28 ` Michael Ellerman
2019-07-30 14:41 ` Stephen Rothwell
2019-07-30 17:07 ` Kees Cook
2019-07-30 20:37 ` Benjamin Herrenschmidt
2019-07-31 11:46 ` Michael Ellerman [this message]
2019-08-02 2:28 ` Michael Ellerman
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=87ef26qvdx.fsf@concordia.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=benh@kernel.crashing.org \
--cc=gustavo@embeddedor.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=sfr@canb.auug.org.au \
/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
Powered by JetHome