Re: [PATCH v1 1/1] usb: f_mass_storage: Bump local buffer size in fsg_common_create_luns()

Alan Stern <[email protected]>
Newsgroups org.kernel.vger.linux-usb,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon, Aug 17, 2026 at 12:47:34PM +0200, Andy Shevchenko wrote:
> GCC is not happy about the buffer size:
> 
> drivers/usb/gadget/function/f_mass_storage.c:2970:48: error: ā€˜%d’ directive output may be truncated writing between 1 and 9 bytes into a region of size 5 [-Werror=format-truncation=]
> 
> Bump the size to get it enough for all possible values.
> 
> Note, the existing comment is wrong as size 8 for the whole buffer doesn't
> cover 100 mil numbers, hence drop it altogether.

It seems highly unlikely that anyone would ever want to create 100 
million LUNs.  Why not limit the number of LUNs to some more reasonable 
value, like 1000?

Alan Stern

> Fixes: b27c08c953e9 ("usb: gadget: f_mass_storage: create lun creation helpers for use in fsg_common_init")
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
>  drivers/usb/gadget/function/f_mass_storage.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
> index b7b06cb79ff5..3d1823b74cd3 100644
> --- a/drivers/usb/gadget/function/f_mass_storage.c
> +++ b/drivers/usb/gadget/function/f_mass_storage.c
> @@ -2961,7 +2961,7 @@ EXPORT_SYMBOL_GPL(fsg_common_create_lun);
>  
>  int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg)
>  {
> -	char buf[8]; /* enough for 100000000 different numbers, decimal */
> +	char buf[14];
>  	int i, rc;
>  
>  	fsg_common_remove_luns(common);
> -- 
> 2.50.1
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.