All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kishore Batta" <kishore.batta@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v9 2/7] bus: mhi: Move Sahara protocol driver under MHI host client drivers
Date: Tue, 13 Oct 2026 09:00:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-169293@kernel.org> (raw)
In-Reply-To: <20261013-sahara_protocol_new_v2-v9-2-dc9f24357c4a@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] qaic: leak of timesync and ras drivers on init failure
- [High] mhi: sahara: UAF due to missing read_data_work cancellation
- [Medium] bus: mhi: mhi_sahara module missing MODULE_DEVICE_TABLE for autoloading
- [Medium] kconfig: MHI_SAHARA missing select WANT_DEV_COREDUMP silently drops dumps
--

commit 1096a5d73941553ee9b70087bffc4c550e7d93dd
Author: Kishore Batta <kishore.batta@oss.qualcomm.com>

bus: mhi: Move Sahara protocol driver under MHI host client drivers

This commit moves the Sahara protocol driver from the QAIC accelerator
subsystem to the generic MHI host client drivers. It creates a dedicated
Kconfig and Makefile hierarchy for Sahara. The driver is also converted
to use module_mhi_driver() instead of manual register and unregister hooks.

> diff --git a/drivers/bus/mhi/host/clients/sahara/Kconfig b/drivers/bus/mhi/host/clients/sahara/Kconfig
> new file mode 100644
> index 0000000000000..f1fc7013a2dee
> --- /dev/null
> +++ b/drivers/bus/mhi/host/clients/sahara/Kconfig
> @@ -0,0 +1,15 @@
> +config MHI_SAHARA
> +	tristate "Sahara protocol driver"
> +	depends on MHI_BUS

[Severity: Medium]
Will this silently drop memory dumps on systems without WANT_DEV_COREDUMP
enabled?

Since WANT_DEV_COREDUMP is a hidden symbol (no prompt), users cannot manually
enable it. Because the newly extracted MHI_SAHARA driver advertises memory
dump retrieval and relies on dev_coredumpv(), omitting a select
WANT_DEV_COREDUMP statement means the devcoredump fallback stub might just
free the buffer without warning, leading to a silent loss of functionality.

> diff --git a/drivers/accel/qaic/qaic_drv.c b/drivers/accel/qaic/qaic_drv.c
> index 0acf6cdd44f81..64e87dfaa5603 100644
> --- a/drivers/accel/qaic/qaic_drv.c
> +++ b/drivers/accel/qaic/qaic_drv.c
[ ... ]
> @@ -816,7 +809,6 @@ static int __init qaic_init(void)
>  
>  free_bootlog:
>  	qaic_bootlog_unregister();
> -free_mhi:
>  	mhi_driver_unregister(&qaic_mhi_driver);
>  free_pci:
>  	pci_unregister_driver(&qaic_pci_driver);

[Severity: High]
Does this error path leak the timesync and ras MHI drivers?

If qaic_ssr_register() fails, the code jumps to free_bootlog. This cleanup
path unregisters the bootlog, MHI, and PCI drivers, but skips calling
qaic_timesync_deinit() and qaic_ras_unregister(). 

Because mhi_driver_register() adds these driver structures to the driver
core and sysfs, failing module initialization without unregistering them
leaves dangling pointers to the unloaded module's memory, which could
trigger a use-after-free crash if the bus core subsequently accesses them.

> diff --git a/drivers/accel/qaic/sahara.c b/drivers/bus/mhi/host/clients/sahara/sahara.c
> similarity index 99%
> rename from drivers/accel/qaic/sahara.c
> rename to drivers/bus/mhi/host/clients/sahara/sahara.c
> index c7c0b3eb4b65f..75c0cf6010e15 100644
> --- a/drivers/accel/qaic/sahara.c
> +++ b/drivers/bus/mhi/host/clients/sahara/sahara.c
[ ... ]
> @@ -922,13 +922,7 @@ static struct mhi_driver sahara_mhi_driver = {
>  		.name = "sahara",
>  	},
>  };
> +module_mhi_driver(sahara_mhi_driver);

[Severity: Medium]
Will this driver fail to load automatically when the hardware is detected?

Because the driver is now extracted into an independent module, missing the
MODULE_DEVICE_TABLE macro for sahara_mhi_match_table means the match table
isn't exported to the module alias table. This prevents udev or modprobe
from automatically loading mhi_sahara when the QAIC_SAHARA channel is
detected.

[Severity: High]
Is there a use-after-free risk during device removal if read_data_work
remains pending?

When the device is removed or unbound via sysfs, sahara_mhi_remove() is
called. While fw_work and dump_work are cancelled, read_data_work is
completely omitted:

drivers/bus/mhi/host/clients/sahara/sahara.c:sahara_mhi_remove() {
	struct sahara_context *context = dev_get_drvdata(&mhi_dev->dev);

	cancel_work_sync(&context->fw_work);
	cancel_work_sync(&context->dump_work);
	vfree(context->mem_dump);
	sahara_release_image(context);
	mhi_unprepare_from_transfer(mhi_dev);
}

If read_data_work was scheduled and remains pending, it will execute after
sahara_mhi_remove() returns and access the context structure, which has
already been freed.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013-sahara_protocol_new_v2-v9-0-dc9f24357c4a@oss.qualcomm.com?part=2

  reply	other threads:[~2026-10-13  9:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  8:45 [PATCH v9 0/7] Qualcomm Sahara protocol enhancements Kishore Batta
2026-10-13  8:45 ` [PATCH v9 1/7] Add documentation for Sahara protocol Kishore Batta
2026-10-13  8:51   ` sashiko-bot
2026-10-13  8:45 ` [PATCH v9 2/7] bus: mhi: Move Sahara protocol driver under MHI host client drivers Kishore Batta
2026-10-13  9:00   ` sashiko-bot [this message]
2026-10-13  8:45 ` [PATCH v9 3/7] bus: mhi: Centralize Sahara firmware image table selection at probe time Kishore Batta
2026-10-13  8:45 ` [PATCH v9 4/7] bus: mhi: Add QDU100 Sahara variant and firmware fallback Kishore Batta
2026-10-13  9:01   ` sashiko-bot
2026-10-13  8:45 ` [PATCH v9 5/7] bus: mhi: Load DDR training data using device serial number Kishore Batta
2026-10-13  9:00   ` sashiko-bot
2026-10-13  8:45 ` [PATCH v9 6/7] bus: mhi: Capture DDR training data via command mode Kishore Batta
2026-10-13  8:59   ` sashiko-bot
2026-10-13  8:45 ` [PATCH v9 7/7] bus: mhi: Expose DDR training data via controller sysfs Kishore Batta
2026-10-13  8:58   ` sashiko-bot

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=sashiko-outbox-169293@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kishore.batta@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.