dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] dmaengine: idxd: move dsa_drv support to compatible mode
@ 2021-07-23 13:35 Dan Carpenter
  2021-07-23 15:06 ` Dave Jiang
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-07-23 13:35 UTC (permalink / raw)
  To: dave.jiang; +Cc: dmaengine

Hello Dave Jiang,

The patch 6e7f3ee97bbe: "dmaengine: idxd: move dsa_drv support to
compatible mode" from Jul 15, 2021, leads to the following static
checker warning:

	drivers/dma/idxd/compat.c:66 bind_store()
	error: uninitialized symbol 'alt_drv'.

drivers/dma/idxd/compat.c
    33  static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
    34  {
    35          struct bus_type *bus = drv->bus;
    36          struct device *dev;
    37          struct device_driver *alt_drv;
    38          int rc = -ENODEV;
    39          struct idxd_dev *idxd_dev;
    40  
    41          dev = bus_find_device_by_name(bus, NULL, buf);
    42          if (!dev || dev->driver || drv != &dsa_drv.drv)
    43                  return -ENODEV;
    44  
    45          idxd_dev = confdev_to_idxd_dev(dev);
    46          if (is_idxd_dev(idxd_dev)) {
    47                  alt_drv = driver_find("idxd", bus);
    48                  if (!alt_drv)
    49                          return -ENODEV;
    50          } else if (is_idxd_wq_dev(idxd_dev)) {
                           ^^^^^^^^^^^^^^^^^^^^^^^^
Presumably this condition is always true but the static checker is not
smart enough to figure it out.

    51                  struct idxd_wq *wq = confdev_to_wq(dev);
    52  
    53                  if (is_idxd_wq_kernel(wq)) {
    54                          alt_drv = driver_find("dmaengine", bus);
    55                          if (!alt_drv)
    56                                  return -ENODEV;
    57                  } else if (is_idxd_wq_user(wq)) {
    58                          alt_drv = driver_find("user", bus);
    59                          if (!alt_drv)
    60                                  return -ENODEV;
    61                  } else {
    62                          return -ENODEV;
    63                  }
    64          }
    65  
    66          rc = device_driver_attach(alt_drv, dev);
    67          if (rc < 0)
    68                  return rc;
    69  
    70          return count;
    71  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] dmaengine: idxd: move dsa_drv support to compatible mode
  2021-07-23 13:35 [bug report] dmaengine: idxd: move dsa_drv support to compatible mode Dan Carpenter
@ 2021-07-23 15:06 ` Dave Jiang
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Jiang @ 2021-07-23 15:06 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: dmaengine


On 7/23/2021 6:35 AM, Dan Carpenter wrote:
> Hello Dave Jiang,
>
> The patch 6e7f3ee97bbe: "dmaengine: idxd: move dsa_drv support to
> compatible mode" from Jul 15, 2021, leads to the following static
> checker warning:
>
> 	drivers/dma/idxd/compat.c:66 bind_store()
> 	error: uninitialized symbol 'alt_drv'.


Thanks Dan! This patch should make static checker happy:

https://lore.kernel.org/dmaengine/162689250332.2114335.636367120454420852.stgit@djiang5-desk3.ch.intel.com/T/#u


>
> drivers/dma/idxd/compat.c
>      33  static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
>      34  {
>      35          struct bus_type *bus = drv->bus;
>      36          struct device *dev;
>      37          struct device_driver *alt_drv;
>      38          int rc = -ENODEV;
>      39          struct idxd_dev *idxd_dev;
>      40
>      41          dev = bus_find_device_by_name(bus, NULL, buf);
>      42          if (!dev || dev->driver || drv != &dsa_drv.drv)
>      43                  return -ENODEV;
>      44
>      45          idxd_dev = confdev_to_idxd_dev(dev);
>      46          if (is_idxd_dev(idxd_dev)) {
>      47                  alt_drv = driver_find("idxd", bus);
>      48                  if (!alt_drv)
>      49                          return -ENODEV;
>      50          } else if (is_idxd_wq_dev(idxd_dev)) {
>                             ^^^^^^^^^^^^^^^^^^^^^^^^
> Presumably this condition is always true but the static checker is not
> smart enough to figure it out.
>
>      51                  struct idxd_wq *wq = confdev_to_wq(dev);
>      52
>      53                  if (is_idxd_wq_kernel(wq)) {
>      54                          alt_drv = driver_find("dmaengine", bus);
>      55                          if (!alt_drv)
>      56                                  return -ENODEV;
>      57                  } else if (is_idxd_wq_user(wq)) {
>      58                          alt_drv = driver_find("user", bus);
>      59                          if (!alt_drv)
>      60                                  return -ENODEV;
>      61                  } else {
>      62                          return -ENODEV;
>      63                  }
>      64          }
>      65
>      66          rc = device_driver_attach(alt_drv, dev);
>      67          if (rc < 0)
>      68                  return rc;
>      69
>      70          return count;
>      71  }
>
> regards,
> dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-23 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 13:35 [bug report] dmaengine: idxd: move dsa_drv support to compatible mode Dan Carpenter
2021-07-23 15:06 ` Dave Jiang

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox