diff mbox

[2/8,media] v4l2-async: Delete an error message for a failed memory allocation in v4l2_async_notifier_unregister()

Message ID a00be613-169b-4992-dc29-c4b9e82d5501@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring Dec. 26, 2016, 8:45 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 26 Dec 2016 19:19:49 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/v4l2-core/v4l2-async.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Sakari Ailus Dec. 27, 2016, 11:47 a.m. UTC | #1
On Mon, Dec 26, 2016 at 09:45:50PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 26 Dec 2016 19:19:49 +0100
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> WARNING: Possible unnecessary 'out of memory' message
> 
> Thus fix the affected source code place.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index 277183f2d514..812d0b2a2f73 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -203,11 +203,6 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
>  		return;
>  
>  	dev = kmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
> -	if (!dev) {
> -		dev_err(notifier->v4l2_dev->dev,
> -			"Failed to allocate device cache!\n");
> -	}
> -

I'd leave the empty line where it is.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

>  	mutex_lock(&list_lock);
>  
>  	list_del(&notifier->list);
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mauro Carvalho Chehab Jan. 31, 2017, 9:55 a.m. UTC | #2
Em Mon, 26 Dec 2016 21:45:50 +0100
SF Markus Elfring <elfring@users.sourceforge.net> escreveu:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 26 Dec 2016 19:19:49 +0100
> 
> The script "checkpatch.pl" pointed information out like the following.
> 
> WARNING: Possible unnecessary 'out of memory' message
> 
> Thus fix the affected source code place.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index 277183f2d514..812d0b2a2f73 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -203,11 +203,6 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
>  		return;
>  
>  	dev = kmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
> -	if (!dev) {
> -		dev_err(notifier->v4l2_dev->dev,
> -			"Failed to allocate device cache!\n");
> -	}
> -

In this specific case, we should keep it, as the message means that
the unregister logic won't work properly, as this loop won't run:

        /*
         * Call device_attach() to reprobe devices
         *
         * NOTE: If dev allocation fails, i is 0, and the whole loop won't be
         * executed.
         */
	while (i--) {
                struct device *d = dev[i];

                if (d && device_attach(d) < 0) {
                        const char *name = "(none)";
                        int lock = device_trylock(d);

                        if (lock && d->driver)
                                name = d->driver->name;
                        dev_err(d, "Failed to re-probe to %s\n", name);
                        if (lock)
                                device_unlock(d);
                }
                put_device(d);
        }

So, IMHO, the proper patch would be to change the message to
be more comprehensive, describing the consequences of not being
able to allocate the dev cache.


>  	mutex_lock(&list_lock);
>  
>  	list_del(&notifier->list);



Thanks,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 277183f2d514..812d0b2a2f73 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -203,11 +203,6 @@  void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 		return;
 
 	dev = kmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
-	if (!dev) {
-		dev_err(notifier->v4l2_dev->dev,
-			"Failed to allocate device cache!\n");
-	}
-
 	mutex_lock(&list_lock);
 
 	list_del(&notifier->list);