[PATCH v4 3/6] imx-drm: imx-ldb: Use snprintf()
Greg KH
gregkh at linuxfoundation.org
Thu Feb 27 22:54:43 UTC 2014
On Wed, Feb 26, 2014 at 08:53:41PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam at freescale.com>
>
> Use snprintf() in order to fix the following static checker warning:
>
> drivers/staging/imx-drm/imx-ldb.c:340 imx_ldb_get_clk() error: format string overflow. buf_size: 16 length: 18
> probably 18 is theory and not real life, but 16 is based on
> theory as well.
>
> Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
> Signed-off-by: Fabio Estevam <fabio.estevam at freescale.com>
> ---
> Changes since v3:
> - Fix Subject
> - Also use snprintf in the other ocurrence
> Changes since v2:
> - Use snprintf as suggested by Russell
> Changes since v1:
> - None
>
> drivers/staging/imx-drm/imx-ldb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c
> index abf8517..daa54df 100644
> --- a/drivers/staging/imx-drm/imx-ldb.c
> +++ b/drivers/staging/imx-drm/imx-ldb.c
> @@ -334,12 +334,12 @@ static int imx_ldb_get_clk(struct imx_ldb *ldb, int chno)
> {
> char clkname[16];
>
> - sprintf(clkname, "di%d", chno);
> + snprintf(clkname, sizeof(clkname), "di%d", chno);
Are you sure this can not overflow as well? Strings in C are nasty...
More information about the devel
mailing list