[bug report] IB/uverbs: Add read counters support

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

 



Hello Raed Salem,

The patch ebb6796bd397: "IB/uverbs: Add read counters support" from
May 31, 2018, leads to the following static checker warning:

	drivers/infiniband/core/uverbs_std_types_counters.c:105 ib_uverbs_handler_UVERBS_METHOD_COUNTERS_READ()
	error: 'uattr' dereferencing possible ERR_PTR()

drivers/infiniband/core/uverbs_std_types_counters.c
    83  static int UVERBS_HANDLER(UVERBS_METHOD_COUNTERS_READ)(struct ib_device *ib_dev,
    84                                                         struct ib_uverbs_file *file,
    85                                                         struct uverbs_attr_bundle *attrs)
    86  {
    87          struct ib_counters_read_attr read_attr = {};
    88          const struct uverbs_attr *uattr;
    89          struct ib_counters *counters =
    90                  uverbs_attr_get_obj(attrs, UVERBS_ATTR_READ_COUNTERS_HANDLE);
    91          int ret;
    92  
    93          if (!ib_dev->read_counters)
    94                  return -EOPNOTSUPP;
    95  
    96          if (!atomic_read(&counters->usecnt))
    97                  return -EINVAL;
    98  
    99          ret = uverbs_copy_from(&read_attr.flags, attrs,
   100                                 UVERBS_ATTR_READ_COUNTERS_FLAGS);
   101          if (ret)
   102                  return ret;
   103  
   104          uattr = uverbs_attr_get(attrs, UVERBS_ATTR_READ_COUNTERS_BUFF);
                ^^^^^^^^^^^^^^^^^^^^^^^
Does this require error handling?

   105          read_attr.ncounters = uattr->ptr_attr.len / sizeof(u64);
   106          read_attr.counters_buff = kcalloc(read_attr.ncounters,
   107                                            sizeof(u64), GFP_KERNEL);
   108          if (!read_attr.counters_buff)
   109                  return -ENOMEM;
   110  
   111          ret = ib_dev->read_counters(counters,
   112                                      &read_attr,
   113                                      attrs);
   114          if (ret)
   115                  goto err_read;
   116  
   117          ret = uverbs_copy_to(attrs, UVERBS_ATTR_READ_COUNTERS_BUFF,
   118                               read_attr.counters_buff,
   119                               read_attr.ncounters * sizeof(u64));
   120  
   121  err_read:
   122          kfree(read_attr.counters_buff);
   123          return ret;
   124  }

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux