Skip to contentSkip to conversation

drivers/tty/serial: sprintf for filename[32].

Suggestion Chen Gang 1 participant 1 message Dec 1, 2012 TTY layer and serial drivers

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

Hello Alan Cox:

in drives/tty/serial/ucc_uart.c:
at line 1231, the filename buffer length is 32.
at line 1242, "fsl_qe_ucode_uart_%u_%u%u.bin" is 23 + 3*%u.
at line 1237, after call soc_info. soc within 4 bytes, rev_h within 2 bytes, rev_l within 2 bytes.

my suggestion is:
use "fsl_qe_ucode_uart_%.4u_%.2u%.2u.bin" instead of "fsl_qe_ucode_uart_%u_%u%u.bin"; or use "char filename[64]" instead of "char filename[32]".
please give your choice (or provide new choice).

it is not a bug, it is only to make source code clearer or extensible.

thanks.

1231 } else {

1232                         char filename[32];
1233                         unsigned int soc;
1234                         unsigned int rev_h;
1235                         unsigned int rev_l;

1236
1237 soc = soc_info(&rev_h, &rev_l);
1238 if (!soc) {
1239 dev_err(&ofdev->dev, "unknown CPU model\n");
1240 return -ENXIO;
1241 }
1242 sprintf(filename, "fsl_qe_ucode_uart_%u_%u%u.bin",
1243 soc, rev_h, rev_l);
1244
1245 dev_info(&ofdev->dev, "waiting for firmware %s\n",
1246 filename);
1247

Signature · 3 lines
Chen Gang

Asianux Corporation