Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1639891

Re: [PATCH 2/4] vmbus: Delete an error message for a failed memory allocation in vmbus_device_create()

From Stephen Hemminger <stephen@networkplumber.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/4] vmbus: Delete an error message for a failed memory allocation in vmbus_device_create()
Date 2017-05-11 18:40 +0200
Message-ID <tFZia-ha-31@gated-at.bofh.it> (permalink)
References <tFYYN-ax-9@gated-at.bofh.it> <tFYYN-ax-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 11 May 2017 18:17:01 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 11 May 2017 17:33:14 +0200
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/hv/vmbus_drv.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 6802d74f162c..96328aebae5a 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1149,7 +1149,5 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
> -	if (!child_device_obj) {
> -		pr_err("Unable to allocate device object for child device\n");
> +	if (!child_device_obj)
>  		return NULL;
> -	}
>  
>  	child_device_obj->channel = channel;
>  	memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le));

Taking out the message assumes that all callers of this function either log an
error or pass appropriate error code back to userspace. Did you walk back
through all the callers?

Just because an automated tool says that this needs to change does not
mean it has to.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/4] vmbus: Delete an error message for a failed memory  allocation in vmbus_device_create() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-11 18:20 +0200
  Re: vmbus: Delete an error message for a failed memory allocation in  vmbus_device_create() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-11 18:40 +0200
    Re: vmbus: Delete an error message for a failed memory allocation  in vmbus_device_create() Stephen Hemminger <stephen@networkplumber.org> - 2017-05-11 18:50 +0200
  Re: [PATCH 2/4] vmbus: Delete an error message for a failed memory  allocation in vmbus_device_create() Stephen Hemminger <stephen@networkplumber.org> - 2017-05-11 18:40 +0200
    Re: [PATCH 2/4] vmbus: Delete an error message for a failed memory  allocation in vmbus_device_create() Dan Carpenter <dan.carpenter@oracle.com> - 2017-05-12 09:20 +0200
      Re: vmbus: Delete an error message for a failed memory allocation in  vmbus_device_create() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-12 09:40 +0200
        Re: vmbus: Delete an error message for a failed memory allocation  in vmbus_device_create() Joe Perches <joe@perches.com> - 2017-05-12 10:00 +0200
          Re: Clarification for general change acceptance SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-12 10:30 +0200
            Re: Clarification for general change acceptance Julia Lawall <julia.lawall@lip6.fr> - 2017-05-12 10:40 +0200
              Re: Clarification for general change acceptance SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-12 10:50 +0200

csiph-web