From: Dave Jiang <dave.jiang@intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
vkoul@kernel.org, dan.j.williams@intel.com
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] dmaengine: idxd: Fix a possible NULL pointer dereference
Date: Thu, 29 Jul 2021 09:12:03 -0700 [thread overview]
Message-ID: <44c9607e-2cde-02b9-7e4e-68578a775fb3@intel.com> (raw)
In-Reply-To: <77f0dc4f3966591d1f0cffb614a94085f8895a85.1627560174.git.christophe.jaillet@wanadoo.fr>
On 7/29/2021 5:04 AM, Christophe JAILLET wrote:
> '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: 568b2126466f ("dmaengine: idxd: fix uninit var for alt_drv")
> Fixes: 6e7f3ee97bbe ("dmaengine: idxd: move dsa_drv support to compatible mode")
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Thanks for the cleanup.
Acked-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/dma/idxd/compat.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c
> index d7616c240dcd..3df21615f888 100644
> --- a/drivers/dma/idxd/compat.c
> +++ b/drivers/dma/idxd/compat.c
> @@ -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)
next prev parent reply other threads:[~2021-07-29 16:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-29 12:04 [PATCH] dmaengine: idxd: Fix a possible NULL pointer dereference Christophe JAILLET
2021-07-29 16:12 ` Dave Jiang [this message]
2021-08-02 7:05 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44c9607e-2cde-02b9-7e4e-68578a775fb3@intel.com \
--to=dave.jiang@intel.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.