All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Rusty Russell <rusty@rustcorp.com.au>,
	Christoph Jaeger <christophjaeger@linux.com>
Cc: linux-kernel@vger.kernel.org,
	Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>,
	Jon Mason <jon.mason@intel.com>,
	tech.support@emulex.com, David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH 1/1] module: fix sprintf format specifier in param_get_byte()
Date: Wed, 07 Aug 2013 13:31:30 +0200	[thread overview]
Message-ID: <xa1tli4d20vh.fsf@mina86.com> (raw)
In-Reply-To: <87y58eov9u.fsf@rustcorp.com.au>

[-- Attachment #1: Type: text/plain, Size: 2207 bytes --]

On Wed, Aug 07 2013, Rusty Russell wrote:
> Christoph Jaeger <christophjaeger@linux.com> writes:
>> In param_get_byte(), to which the macro STANDARD_PARAM_DEF(byte, ...) expands,
>> "%c" is used to print an unsigned char. So it gets printed as a character what
>> is not intended here. Use "%hhu" instead.
>>
>> Signed-off-by: Christoph Jaeger <christophjaeger@linux.com>

Acked-by: Michal Nazarewicz <mina86@mina86.com>

for g_ffs.c:

> drivers/usb/gadget/g_ffs.c:95:module_param_named(bDeviceClass,    gfs_dev_desc.bDeviceClass,    byte,   0644);
> drivers/usb/gadget/g_ffs.c:97:module_param_named(bDeviceSubClass, gfs_dev_desc.bDeviceSubClass, byte,   0644);
> drivers/usb/gadget/g_ffs.c:99:module_param_named(bDeviceProtocol, gfs_dev_desc.bDeviceProtocol, byte,   0644);

I don't think it breaks anything for g_ffs since those properties are
most likely write-only and I don't expect many people reading them.

>> ---
>>  kernel/params.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/params.c b/kernel/params.c
>> index 440e65d..59f7ac7 100644
>> --- a/kernel/params.c
>> +++ b/kernel/params.c
>> @@ -252,7 +252,7 @@ int parse_args(const char *doing,
>>  	EXPORT_SYMBOL(param_ops_##name)
>>  
>>  
>> -STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, strict_strtoul);
>> +STANDARD_PARAM_DEF(byte, unsigned char, "%hhu", unsigned long, strict_strtoul);
>>  STANDARD_PARAM_DEF(short, short, "%hi", long, strict_strtol);
>>  STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, strict_strtoul);

Actually, are those “h” specifiers even necessary?  I'm fairly certain
that “%u” for byte, “%i” for short, and “%u” for ushort would work just
fine since the argument gets promoted to (unsigned) int anyway and
indeed vsnprintf reads an int for all those types.

>>  STANDARD_PARAM_DEF(int, int, "%i", long, strict_strtol);

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

  reply	other threads:[~2013-08-07 11:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 21:12 [PATCH 1/1] module: fix sprintf format specifier in param_get_byte() Christoph Jaeger
2013-08-06 23:39 ` Joe Perches
2013-08-07  6:43 ` Rusty Russell
2013-08-07 11:31   ` Michal Nazarewicz [this message]
2013-08-07 16:45   ` Jon Mason

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=xa1tli4d20vh.fsf@mina86.com \
    --to=mina86@mina86.com \
    --cc=christophjaeger@linux.com \
    --cc=dmitry.tarnyagin@lockless.no \
    --cc=dwmw2@infradead.org \
    --cc=jon.mason@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tech.support@emulex.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.