Commit e9c5b0b5 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Vinod Koul

dmaengine: idxd: Fix a possible NULL pointer dereference

'device_driver_attach()' dereferences its first argument (i.e. 'alt_drv')
so it must not be NULL.
Simplify the error handling logic about NULL 'alt_drv' in order to be
more robust and future-proof.

Fixes: 568b2126 ("dmaengine: idxd: fix uninit var for alt_drv")
Fixes: 6e7f3ee9 ("dmaengine: idxd: move dsa_drv support to compatible mode")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: default avatarDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/77f0dc4f3966591d1f0cffb614a94085f8895a85.1627560174.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent ffa179ae
......@@ -45,23 +45,16 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t cou
idxd_dev = confdev_to_idxd_dev(dev);
if (is_idxd_dev(idxd_dev)) {
alt_drv = driver_find("idxd", bus);
if (!alt_drv)
return -ENODEV;
} else if (is_idxd_wq_dev(idxd_dev)) {
struct idxd_wq *wq = confdev_to_wq(dev);
if (is_idxd_wq_kernel(wq)) {
if (is_idxd_wq_kernel(wq))
alt_drv = driver_find("dmaengine", bus);
if (!alt_drv)
return -ENODEV;
} else if (is_idxd_wq_user(wq)) {
else if (is_idxd_wq_user(wq))
alt_drv = driver_find("user", bus);
if (!alt_drv)
return -ENODEV;
} else {
return -ENODEV;
}
}
if (!alt_drv)
return -ENODEV;
rc = device_driver_attach(alt_drv, dev);
if (rc < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment