[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <xa1tli4d20vh.fsf@mina86.com>
Date: Wed, 07 Aug 2013 13:31:30 +0200
From: Michal Nazarewicz <mina86@...a86.com>
To: Rusty Russell <rusty@...tcorp.com.au>,
Christoph Jaeger <christophjaeger@...ux.com>
Cc: linux-kernel@...r.kernel.org,
Dmitry Tarnyagin <dmitry.tarnyagin@...kless.no>,
Jon Mason <jon.mason@...el.com>, tech.support@...lex.com,
David Woodhouse <dwmw2@...radead.org>
Subject: Re: [PATCH 1/1] module: fix sprintf format specifier in param_get_byte()
On Wed, Aug 07 2013, Rusty Russell wrote:
> Christoph Jaeger <christophjaeger@...ux.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@...ux.com>
Acked-by: Michal Nazarewicz <mina86@...a86.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@...gle.com>--------------ooO--(_)--Ooo--
Download attachment "signature.asc" of type "application/pgp-signature" (836 bytes)
Powered by blists - more mailing lists