Re: [RFC PATCH 03/57] drivers: coresight: Drop device references found via bus_find_device

From: Greg KH
Date: Mon Jun 03 2019 - 15:12:15 EST


On Mon, Jun 03, 2019 at 04:49:29PM +0100, Suzuki K Poulose wrote:
> We must drop references to the device found via bus_find_device().
>
> Cc: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
> ---
> drivers/hwtracing/coresight/coresight.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
> index 4b13028..37ccd67 100644
> --- a/drivers/hwtracing/coresight/coresight.c
> +++ b/drivers/hwtracing/coresight/coresight.c
> @@ -540,7 +540,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
>
> dev = bus_find_device(&coresight_bustype, NULL, &deactivate,
> coresight_enabled_sink);
> -
> + put_device(dev);
> return dev ? to_coresight_device(dev) : NULL;

You drop the reference and then use the pointer?

Not good :(

> }
>
> @@ -581,7 +581,7 @@ struct coresight_device *coresight_get_sink_by_id(u32 id)
>
> dev = bus_find_device(&coresight_bustype, NULL, &id,
> coresight_sink_by_id);
> -
> + put_device(dev);
> return dev ? to_coresight_device(dev) : NULL;

Same here, not good :(

Please fix this up and it can go in as a bugfix like any other normal
patch, outside of this huge series.

thanks,

greg k-h