[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151207132552.478200e3@bbrezillon>
Date: Mon, 7 Dec 2015 13:25:52 +0100
From: Boris Brezillon <boris.brezillon@...e-electrons.com>
To: Nicolas Iooss <nicolas.iooss_linux@....org>
Cc: David Airlie <airlied@...ux.ie>,
Jianwei Wang <jianwei.wang.chn@...il.com>,
Alison Wang <alison.wang@...escale.com>,
Thierry Reding <thierry.reding@...il.com>,
Terje Bergström
<tbergstrom@...dia.com>, dri-devel@...ts.freedesktop.org,
linux-tegra@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm: do not use device name as a format string
On Wed, 18 Nov 2015 18:58:18 +0100
Nicolas Iooss <nicolas.iooss_linux@....org> wrote:
> drm_dev_set_unique() formats its parameter using kvasprintf() but many
> of its callers directly pass dev_name(dev) as printf format string,
> without any format parameter. This can cause some issues when the
> device name contains '%' characters.
>
> To avoid any potential issue, always use "%s" when using
> drm_dev_set_unique() with dev_name().
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@....org>
I'll let Daniel decide whether it's relevant or not to add a new
function/macro to hide this, but I'm fine with the current patch.
[for the atmel-hlcdc driver]
Acked-by: Boris Brezillon <boris.brezillon@...e-electrons.com>
> ---
> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +-
> drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 2 +-
> drivers/gpu/drm/tegra/drm.c | 2 +-
> drivers/gpu/drm/vc4/vc4_drv.c | 2 +-
> include/drm/drmP.h | 1 +
> 5 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index 244df0a440b7..0d720d3a7ee0 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -733,7 +733,7 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)
> if (!ddev)
> return -ENOMEM;
>
> - ret = drm_dev_set_unique(ddev, dev_name(ddev->dev));
> + ret = drm_dev_set_unique(ddev, "%s", dev_name(ddev->dev));
> if (ret)
> goto err_unref;
>
> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> index 1930234ba5f1..947d75f59881 100644
> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> @@ -363,7 +363,7 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
> fsl_dev->np = dev->of_node;
> drm->dev_private = fsl_dev;
> dev_set_drvdata(dev, fsl_dev);
> - drm_dev_set_unique(drm, dev_name(dev));
> + drm_dev_set_unique(drm, "%s", dev_name(dev));
>
> ret = drm_dev_register(drm, 0);
> if (ret < 0)
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index 159ef515cab1..b278f60f4376 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -991,7 +991,7 @@ static int host1x_drm_probe(struct host1x_device *dev)
> if (!drm)
> return -ENOMEM;
>
> - drm_dev_set_unique(drm, dev_name(&dev->dev));
> + drm_dev_set_unique(drm, "%s", dev_name(&dev->dev));
> dev_set_drvdata(&dev->dev, drm);
>
> err = drm_dev_register(drm, 0);
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
> index 6e730605edcc..c90a451aaa79 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.c
> +++ b/drivers/gpu/drm/vc4/vc4_drv.c
> @@ -168,7 +168,7 @@ static int vc4_drm_bind(struct device *dev)
> vc4->dev = drm;
> drm->dev_private = vc4;
>
> - drm_dev_set_unique(drm, dev_name(dev));
> + drm_dev_set_unique(drm, "%s", dev_name(dev));
>
> drm_mode_config_init(drm);
> if (ret)
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 0b921ae06cd8..995fb96cb740 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1049,6 +1049,7 @@ void drm_dev_ref(struct drm_device *dev);
> void drm_dev_unref(struct drm_device *dev);
> int drm_dev_register(struct drm_device *dev, unsigned long flags);
> void drm_dev_unregister(struct drm_device *dev);
> +__printf(2, 3)
> int drm_dev_set_unique(struct drm_device *dev, const char *fmt, ...);
>
> struct drm_minor *drm_minor_acquire(unsigned int minor_id);
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists