[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug report] drm/xen-front: Add support for Xen PV display frontend


  • To: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Tue, 21 Apr 2020 11:34:53 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ErhIsr6nFzZAhpsCBTew5GcZqhDzEM9a0zUDFOef73c=; b=UTgyvoZnG3UxsPfu1vzMXzfvvxLfUOkFSWxS+iU829724sitvfNjTU2N9cTNVCFuqJZJRJvimS3LjAj6P/sdBbTzaGJldpVweomxBsK7yD5Gj58tI1s44cfUvUAXn2dBR710b4Z88JDHtHn+lX3lKO2IQ794Q4reJJif8UCP5cGKNjhhSoWkXO4EKSexpwj7cHHZQNvPgi8MxZy8gCbNF/7Gq4JXpPPFZfPG1n0z9jUgfqi8FWhv1NBxnbfPzSIuT+fAUrJj2iXCFam0H9CUVZcswS3OU4gJnd2qJIER3HA+yNht0OgHfzh8Q8K9Y9P/K2IGGyPBOJyKk25MKvQFoA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HT8rlgSniTOLPbn6PLuOc5HBNs4tPLo2opmh3ypPqT96N3vDwxfzOFBeuzYC3sQJ5LFvtdFSoWk6B+/+v3YKRga7UTmJZGX2aGr9SDuvV2YqmUvkAjT9YKWeaqj0Y5FzeveRywsKx4iITeXLrQNWDkDOk+67nIFv4eYdaGHW3OHzIeG+G5JGoSccL2aOy6ZyzyuZ8nQv0EFODnWHzI+5KrvT7+rg427ihSnawyiUWuxIrj9LJZX69vSPRwle5VMqBmTZPvRZHVov4JkDeWT32C0nWTrsmVHP629yFqfwNcz6JhUx6XDvd0J+OY/ucwi4HaughIjCDZJcS9RkpH5svA==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Oleksandr_Andrushchenko@xxxxxxxx;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "kernel-janitors@xxxxxxxxxxxxxxx" <kernel-janitors@xxxxxxxxxxxxxxx>, "dri-devel@xxxxxxxxxxxxxxxxxxxxx" <dri-devel@xxxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 21 Apr 2020 11:35:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWF8n8HYXBbl5N3kSvZpSjxllEBqiDciuA
  • Thread-topic: [bug report] drm/xen-front: Add support for Xen PV display frontend

On 4/21/20 13:45, Dan Carpenter wrote:
> Hi Kernel Janitors,
Hi
>
> Here is another idea that someone could work on, fixing the
> IS_ERR_OR_NULL() checks in the xen driver.
>
> The patch c575b7eeb89f: "drm/xen-front: Add support for Xen PV
> display frontend" from Apr 3, 2018, leads to the following static
> checker warning:
>
>       drivers/gpu/drm/xen/xen_drm_front_gem.c:140 xen_drm_front_gem_create()
>       warn: passing zero to 'ERR_CAST'
>
> drivers/gpu/drm/xen/xen_drm_front_gem.c
>     133  struct drm_gem_object *xen_drm_front_gem_create(struct drm_device 
> *dev,
>     134                                                  size_t size)
>     135  {
>     136          struct xen_gem_object *xen_obj;
>     137
>     138          xen_obj = gem_create(dev, size);
>     139          if (IS_ERR_OR_NULL(xen_obj))
>     140                  return ERR_CAST(xen_obj);
>
> This warning is old and it's actually the result of a bug I had in my
> devel version of Smatch yesterday.  xen_obj can't really be NULL, but
> if it were then the caller would return success which would probably
> create some issues.
>
> When a function returns both error pointers and NULL then NULL is a
> special case of success.  Like say you have:  "p = start_feature();".
> If there is an allocation failure, then the code should return -ENOMEM
> and the whole thing should fail.  But if the feature is optional and
> the user has disabled it in the config then we return NULL and the
> caller has to be able to accept that.  There are a lot of these
> IS_ERR_OR_NULL() checks in the xen driver...
>
> The one here is clearly buggy because returning NULL would lead to a
> run time failure.  All these IS_ERR_OR_NULL() should be checked and
> probably changed to just IS_ERR().
>
> This sort of change is probably change is probably easiest if you build
> the Smatch DB and you can check if Smatch thinks the functions return
> NULL.
>
> ~/smatch/smatch_data/db/smdb.py return_states gem_create | grep INTERNAL
> drivers/gpu/drm/xen/xen_drm_front_gem.c | gem_create | 58 |  (-4095)-(-1) |   
>    INTERNAL |  -1 |                      | struct xen_gem_object*(*)(struct 
> drm_device*, ulong) |
> drivers/gpu/drm/xen/xen_drm_front_gem.c | gem_create | 62 | 
> 4065035897849303040 |      INTERNAL |  -1 |                      | struct 
> xen_gem_object*(*)(struct drm_device*, ulong) |
> drivers/gpu/drm/xen/xen_drm_front_gem.c | gem_create | 66 | 
> 4065035897849303040 |      INTERNAL |  -1 |                      | struct 
> xen_gem_object*(*)(struct drm_device*, ulong) |
> drivers/gpu/drm/xen/xen_drm_front_gem.c | gem_create | 68 | 0,(-4095)-(-1) |  
>     INTERNAL |  -1 |                      | struct xen_gem_object*(*)(struct 
> drm_device*, ulong) |
>
> Smatch thinks that gem_create() sometimes returns NULL or error pointers
> but that's because of a bug in the unreleased version of Smatch and
> because gem_create() uses IS_ERR_OR_NULL().
>
>     141
>     142          return &xen_obj->base;
>     143  }
>
> regards,
> dan carpenter

Thank you for the report, I will try to find some time to look into this 
and come up with fixes.

Could you please (probably off-list) instruct me or give any pointers to 
how to reproduce

the results of the analyzer shown above?

Thank you,

Oleksandr

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.