From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796283229; b=3Yb/ia84D9TQHOqH/dAMC/C7NKr6EAP7ho7SNIa+ihop3CbSYR47RBzLpA8DuPp2FZ5c 5z5CDjSa3YHqEkYit7wWeUtTAr4wzOPjYBT9S7e/61RBf5FAhRq0GPHBUG6S67QXQeSv0 WMoys6Z505OwhX4wApX8wtRtGPVoF2KaIVFGcYC/uvftJKhTVsAJlcBC8mCDCliLGzbPb p6uGGpgNh56ucxkPVSa3o3OYcrvQPTn8cklCfdqKrhencuuSNK0ZKuJJeRkYt/d3ddr8M tiXdi+PmZ4QyuRW3TxJNdVkNP/FjiRCVvfR0rWVwv+2mNsDVVBvy752gohTK/eVd2dA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283229; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=zdBxTBbPTxwuc0KS3peEe+nSUVSzu3exC5TSIHkxmlw=; b=JfNg0AyRV7DUpkoOo9qh2A1b3JpFVU7cp7L8jSmZI4KoUxfxo5qhO9egvsG5JBdFkWd6 dhoNQeek+ldCFfTIxSZ/JA5eKop0TS4gTsaXvOtdXg4puASII+moZ13VsZLg/KYTejMdN Gh32OG5yKb0g2azxv9OKLJ2bvZQY+N+QZ5yoom210fkN9HytLjiIlwhlGeD38d736kqPN b8qJvd5Xu+WsmzAEF6DHtIaKfjW6rXq8YcWz1s6nblxwYm6yAdN1o25oLMrNjQcs4AOWc cJdg3t1TLUuJiLGT829fM2aL+nP9rflOhXMv88iIc4vdQBXPo1flsvnsC6FFriFL+vQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OhETJWyR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79BD4606A322 for ; Thu, 3 Dec 2026 07:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OhETJWyR Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5AF41F000C1; Thu, 3 Dec 2026 07:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796283229; bh=zdBxTBbPTxwuc0KS3peEe+nSUVSzu3exC5TSIHkxmlw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=OhETJWyRgdAuFTVuTryMarc1xrq2cI41ks82vTwJI3iCWIgoe1Uql9BuDsj5QDtt0 jRcniRT8VQ0g/UkkoebIuXKur+AQZsyyd3Va6O5ojzmL4q6+lAElG7pOOpl8R9MqJg C88veBND1W1FjAUwXXk4PhheBnYk0tSCdy2MislHxp/11O5AWli5BcipoUeHTqCfDo m97qmPrcVN2xvl9JJVIl396aSLBB/xFLE0DMHFnMGRj8DpTVrN+dvLONbXBxHMNW9+ Fe+POJdnu4n5iHnrpEkeNpU8Yg9YAoYNFdrO5xALesgf1U/5vYlgiyKHvxiQiwtmQO i7id5Q0eW81aw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 04/17] wifi: cc33xx: Add sdio.c, io.c, io.h Reply-To: sashiko-reviews@lists.linux.dev To: "Ramesh Ramalingam" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203070906.1294171-5-r-ramalingam@ti.com> References: <20261203070906.1294171-1-r-ramalingam@ti.com> <20261203070906.1294171-5-r-ramalingam@ti.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:33:48 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 17 potential issues to consider: - [High] wifi: cc33xx: uninitialized struct resource in sdio_cc33xx_probe() - [High] wifi: cc33xx: use-after-free before IRQ teardown in sdio_cc33xx_remove() - [High] wifi: cc33xx: deadlock and sleep-in-atomic in cc33xx_sdio_disable_irq() - [Medium] wifi: cc33xx: use-after-free before free_irq() in sdio_cc33xx_probe() - [Medium] wifi: cc33xx: runtime PM ref leak in cc33xx_sdio_power_on() on error - [Medium] wifi: cc33xx: unbalanced pm_runtime_put_noidle() on probe failure - [Medium] wifi: cc33xx: missing disable_irq_wake() on sdio_cc33xx_probe() error - [Medium] wifi: cc33xx: cc33xx_suspend() returns -EINVAL when core driver unbound - [Medium] wifi: cc33xx: cc33xx_probe_of() loses -EPROBE_DEFER from DT IRQ parse - [Medium] wifi: cc33xx: unchecked sdio_f0_readb() in cc33xx_enable_async_interrupt() - [Medium] wifi: cc33xx: ignored sdio_claim_irq() error in cc33xx_sdio_enable_irq() - [Medium] wifi: cc33xx: cc33xx_sdio_set_block_size() ignores block-size error - [Low] wifi: cc33xx: unprefixed global lock helpers and void* IRQ handler - [Low] wifi: cc33xx: prohibited linux/gpio.h include and missing headers in sdio.c - [Low] wifi: cc33xx: unused include of deprecated linux/gpio.h in sdio.c - [Low] wifi: cc33xx: local SDIO IDs and early quirk mutation in sdio_cc33xx_probe() - [Low] wifi: cc33xx: IRQ_NOAUTOEN flag leaked in sdio_cc33xx_probe() -- commit a2cbcc4a1c662264be0a93163a1e9980d328c46f Author: Michael Nemanov wifi: cc33xx: Add sdio.c, io.c, io.h This commit adds the SDIO transport driver and abstract I/O wrapper layer for TI CC33xx wireless devices, supporting both out-of-band GPIO and in-band SDIO interrupts. > diff --git a/drivers/net/wireless/ti/cc33xx/io.h b/drivers/net/wireless/t= i/cc33xx/io.h > new file mode 100644 > index 0000000000000..35f6d4b483a6b > --- /dev/null > +++ b/drivers/net/wireless/ti/cc33xx/io.h [ ... ] > +void claim_core_status_lock(struct cc33xx *cc); > +void release_core_status_lock(struct cc33xx *cc); [Severity: Low] Should claim_core_status_lock() and release_core_status_lock() carry the cc33xx_ prefix used by the other helpers in io.h to avoid putting generic names into the global symbol namespace when built into vmlinux? Similarly, cc33xx_set_irq_handler() in sdio.c takes an untyped void * handler and assigns it to pdev_data->irq_handler, bypassing compile-time prototype checking instead of taking a typed function pointer. > diff --git a/drivers/net/wireless/ti/cc33xx/sdio.c b/drivers/net/wireless= /ti/cc33xx/sdio.c > new file mode 100644 > index 0000000000000..5edbe1ebc7a80 > --- /dev/null > +++ b/drivers/net/wireless/ti/cc33xx/sdio.c > @@ -0,0 +1,515 @@ [ ... ] > +#include [Severity: Low] This file does not call any GPIO APIs, and include/linux/gpio.h is deprecated with a notice that it must not be included by new code. Can this include be dropped? > +#include > +#include > + > +#include "cc33xx.h" > +#include "io.h" [Severity: Low] In addition to the prohibited linux/gpio.h include, sdio.c includes io.h without using any declaration from it, while relying on transitive includes for linux/module.h, linux/mmc/card.h, linux/interrupt.h, linux/irq.h, and linux/of.h. Adding direct includes for the APIs used here will keep this file resilient to header cleanups. > + > +#ifndef SDIO_VENDOR_ID_TI > +#define SDIO_VENDOR_ID_TI 0x0097 > +#endif > + > +#define SDIO_DEVICE_ID_CC33XX_NO_EFUSE 0x4076 > +#define SDIO_DEVICE_ID_TI_CC33XX 0x4077 [Severity: Low] Should these IDs use linux/mmc/sdio_ids.h instead of local definitions? sdio_ids.h already defines SDIO_VENDOR_ID_TI and 0x4076 as SDIO_DEVICE_ID_TI_WL1271, so exporting 0x0097:0x4076 in cc33xx_devices[] collides with wlcore_sdio's modalias and causes both modules to autoload on 0x0097:0x4076 hardware. In addition, sdio_cc33xx_probe() sets MMC_QUIRK_LENIENT_FN0 and MMC_QUIRK_BLKSZ_FOR_BYTE_MODE on the shared func->card->quirks before cc33xx_probe_of() confirms the device matches ti,cc3300, mutating card state even when rejecting a non-CC33xx card with -ENODEV. [ ... ] > +static void cc33xx_sdio_set_block_size(struct device *child, > + unsigned int blksz) > +{ > + struct cc33xx_sdio_glue *glue =3D dev_get_drvdata(child->parent); > + struct sdio_func *func =3D dev_to_sdio_func(glue->dev); > + > + sdio_claim_host(func); > + sdio_set_block_size(func, blksz); > + sdio_release_host(func); > +} [Severity: Medium] Why is the return value of sdio_set_block_size() discarded here? When sdio_set_block_size() fails (for example with -EINVAL or an FBR write error), func->cur_blksize is left unchanged, yet cc33xx_set_block_size() in io.c unconditionally returns true. cc33xx_chip_wakeup() relies on a false return to clear CC33XX_QUIRK_TX_BLOCKSIZE_ALIGN, so subsequent transfers would use a mismatched block size. [ ... ] > +static int cc33xx_sdio_power_on(struct cc33xx_sdio_glue *glue) > +{ > + int ret; > + struct sdio_func *func =3D dev_to_sdio_func(glue->dev); > + struct mmc_card *card =3D func->card; > + > + ret =3D pm_runtime_get_sync(&card->dev); > + if (ret < 0) { > + pm_runtime_put_noidle(&card->dev); > + dev_err(glue->dev, "%s: failed to get_sync(%d)\n", > + __func__, ret); > + > + return ret; > + } > + > + sdio_claim_host(func); > + ret =3D sdio_enable_func(func); > + sdio_release_host(func); > + > + return ret; > +} [Severity: Medium] Does this leak a runtime PM reference on card->dev when sdio_enable_func() fails? If sdio_enable_func() returns an error, cc33xx_power_on() leaves CC33XX_FLAG_GPIO_POWER clear, so cc33xx_power_off() will not call cc33xx_sdio_power_off() to drop the reference taken by pm_runtime_get_sync(). Calling pm_runtime_put(&card->dev) on error (and using pm_runtime_resume_and_get()) would keep the count balanced. [ ... ] > +static void cc33xx_enable_async_interrupt(struct sdio_func *func) > +{ > + u8 reg_val; > + const int CCCR_REG_16_ADDR =3D 0x16; > + const int ENABLE_ASYNC_IRQ_BIT =3D BIT(1); > + > + reg_val =3D sdio_f0_readb(func, CCCR_REG_16_ADDR, NULL); > + reg_val |=3D ENABLE_ASYNC_IRQ_BIT; > + sdio_f0_writeb(func, reg_val, CCCR_REG_16_ADDR, NULL); > +} [Severity: Medium] Can ignoring the error from sdio_f0_readb() corrupt CCCR register 0x16? sdio_f0_readb() returns 0xFF on a transfer error, so without checking err_ret a transient CMD52 read failure causes sdio_f0_writeb() to write 0xFF back to SDIO_CCCR_INTERRUPT_EXT and clobber reserved bits. This also sets EAI without checking SDIO_INTERRUPT_EXT_SAI or updating func->card->cccr.enable_async_irq, and duplicates SDIO_CCCR_INTERRUPT_EXT and SDIO_INTERRUPT_EXT_EAI from linux/mmc/sdio.h. > + > +static void cc33xx_sdio_enable_irq(struct device *child) > +{ > + struct cc33xx_sdio_glue *glue =3D dev_get_drvdata(child->parent); > + struct sdio_func *func =3D dev_to_sdio_func(glue->dev); > + > + sdio_claim_host(func); > + cc33xx_enable_async_interrupt(func); > + sdio_claim_irq(func, inband_irq_handler); > + sdio_release_host(func); > +} [Severity: Medium] Does discarding the return value of sdio_claim_irq() hide in-band IRQ registration failures? If sdio_claim_irq() fails (for example with -EBUSY or an SDIO I/O error), func->irq_handler stays NULL and the driver silently receives no in-band interrupts until later boot or command timeouts. > + > +static void cc33xx_sdio_disable_irq(struct device *child) > +{ > + struct cc33xx_sdio_glue *glue =3D dev_get_drvdata(child->parent); > + struct sdio_func *func =3D dev_to_sdio_func(glue->dev); > + > + sdio_claim_host(func); > + sdio_release_irq(func); > + sdio_release_host(func); > +} [Severity: High] Can cc33xx_sdio_disable_irq() sleep in atomic context and self-deadlock when invoked through cc33xx_disable_interrupts_nosync()? Unlike disable_irq_nosync() in the GPIO IRQ path, cc33xx_sdio_disable_irq() calls sleeping sdio_claim_host() and sdio_release_irq(), which calls kthread_stop(host->sdio_irq_thread). When an in-band SDIO IRQ arrives while CC33XX_FLAG_SUSPENDED is set, the IRQ thread calls back into cc33xx_sdio_disable_irq() under cc->cc_lock: sdio_irq_thread inband_irq_handler() ... -> cc33xx_irq() spin_lock_irqsave(&cc->cc_lock) cc33xx_disable_interrupts_nosync() cc33xx_sdio_disable_irq() sdio_claim_host() <-- sleep in atomic context sdio_release_irq() kthread_stop(current) <-- self-deadlock In addition, sdio_claim_irq() and sdio_release_irq() do not provide the nested disable-depth semantics of enable_irq() and disable_irq_nosync(). [ ... ] > +static int cc33xx_probe_of(struct device *dev, int *irq, int *wakeirq, > + struct cc33xx_platdev_data *pdev_data) > +{ > + struct device_node *np =3D dev->of_node; > + const struct of_device_id *of_id; > + > + of_id =3D of_match_node(cc33xx_sdio_of_match_table, np); > + if (!of_id) > + return -ENODEV; > + > + pdev_data->family =3D of_id->data; > + > + *irq =3D irq_of_parse_and_map(np, 0); > + > + *wakeirq =3D irq_of_parse_and_map(np, 1); > + > + return 0; > +} [Severity: Medium] Does irq_of_parse_and_map() lose -EPROBE_DEFER when the GPIO interrupt controller has not probed yet? irq_of_parse_and_map() returns 0 both when the interrupts property is omitted and when the IRQ domain is not yet registered, so sdio_cc33xx_probe() silently falls back to sdio_ops_inband_irq instead of deferring probe. Using of_irq_get() distinguishes -EPROBE_DEFER from an absent interrupts property. [ ... ] > + /* Tell PM core that we don't need the card to be powered now */ > + pm_runtime_put_noidle(&func->dev); > + > + glue->core =3D platform_device_alloc("cc33xx", PLATFORM_DEVID_AUTO); > + if (!glue->core) { > + dev_err(glue->dev, "can't allocate platform_device\n"); > + return -ENOMEM; > + } [Severity: Medium] Is pm_runtime_put_noidle(&func->dev) unbalanced on probe failure? sdio_bus_probe() already calls pm_runtime_put_noidle(&func->dev) when drv->probe() returns an error, and neither the -ENOMEM return above nor out_dev_put restores the reference with pm_runtime_get_noresume(&func->dev). Any failure after this point results in a double put on func->dev. [ ... ] > + irq_set_status_flags(gpio_irq, IRQ_NOAUTOEN); > + > + if (irq_flags & (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW)) > + irq_flags |=3D IRQF_ONESHOT; > + > + ret =3D request_threaded_irq(gpio_irq, gpio_irq_hard_handler, > + gpio_irq_thread_handler, > + irq_flags, glue->core->name, func); [Severity: Low] Does calling irq_set_status_flags(gpio_irq, IRQ_NOAUTOEN) leak the IRQ_NOAUTOEN flag on the persistent irq_desc? Neither probe error unwind nor sdio_cc33xx_remove() clears IRQ_NOAUTOEN, so a later consumer of that GPIO IRQ without IRQF_NO_AUTOEN would find its interrupt left disabled. Passing IRQF_NO_AUTOEN in irq_flags to request_threaded_irq() avoids mutating desc->status_use_accessors before acquiring the IRQ. [ ... ] > + if ((mmcflags & MMC_PM_KEEP_POWER) && > + (enable_irq_wake(gpio_irq) =3D=3D 0)) > + pdev_data->pwr_in_suspend =3D true; [Severity: Medium] Does the out_dev_put error path leak the IRQ wake reference enabled here? free_irq() does not decrement desc->wake_depth, so if a subsequent step such as platform_device_add() fails, out_dev_put needs to call disable_irq_wake(pdev_data->gpio_irq_num) when pdev_data->pwr_in_suspend is true. [ ... ] > + if (wakeirq > 0) { > + res[0].start =3D wakeirq; > + res[0].flags =3D IORESOURCE_IRQ | > + irqd_get_trigger_type(irq_get_irq_data(wakeirq)); > + res[0].name =3D "wakeirq"; > + > + ret =3D platform_device_add_resources(glue->core, res, 1); [Severity: High] Can uninitialized fields in res[0] crash platform_device_add()? res[1] is declared on the stack without initialization and only start, flags, and name are written, leaving end, parent, sibling, child, and desc holding stack garbage. platform_device_add() copies res[0] and passes any non-NULL r->parent directly to insert_resource(), dereferencing stack garbage during probe whenever wakeirq is configured. Initializing res[0] with DEFINE_RES_IRQ_NAMED(wakeirq, "wakeirq") (or zero-initializing res and setting res[0].end =3D wakeirq) fixes this. [ ... ] > +out_dev_put: > + platform_device_put(glue->core); > + > + if (pdev_data->gpio_irq_num) > + free_irq(pdev_data->gpio_irq_num, func); > + > + return ret; [Severity: Medium] Can freeing glue->core before free_irq() cause a use-after-free of action->name? request_threaded_irq() stores glue->core->name directly in action->name without copying it, so platform_device_put(glue->core) frees that string while the irqaction is still visible to /proc/interrupts readers. Calling free_irq() before platform_device_put(glue->core) closes that window. > +static void sdio_cc33xx_remove(struct sdio_func *func) > +{ > + struct cc33xx_sdio_glue *glue =3D sdio_get_drvdata(func); > + struct platform_device *pdev =3D glue->core; > + struct cc33xx_platdev_data *pdev_data =3D dev_get_platdata(&pdev->dev); > + > + int gpio_irq_num =3D pdev_data->gpio_irq_num; > + bool pwr_in_suspend =3D pdev_data->pwr_in_suspend; > + > + /* Undo decrement done above in sdio_cc33xx_probe */ > + pm_runtime_get_noresume(&func->dev); > + > + /* Do not use pdev_data after this point */ > + platform_device_unregister(glue->core); > + > + if (gpio_irq_num) { > + free_irq(gpio_irq_num, func); > + if (pwr_in_suspend) > + disable_irq_wake(gpio_irq_num); > + } else { > + sdio_claim_host(func); > + sdio_release_irq(func); > + sdio_release_host(func); > + } > +} [Severity: High] Can an in-flight IRQ handler dereference freed glue->core and pdev_data between platform_device_unregister() and free_irq() / sdio_release_irq()? platform_device_unregister() drops the final reference and frees glue->core, glue->core->name, and pdev_data before free_irq() or sdio_release_irq() synchronizes and removes the IRQ handlers: CPU0 CPU1 sdio_cc33xx_remove() platform_device_unregister(...) platform_device_release() kfree(pdev_data) kfree(glue->core) gpio_irq_thread_handler() dev_get_platdata(&pdev->dev) pdev_data->irq_handler(pdev) <-- use-after-free free_irq(gpio_irq_num, func) The same window also leaves action->name pointing to freed glue->core->name for /proc/interrupts readers. Calling platform_device_del(glue->core), then tearing down the IRQ, and finally calling platform_device_put(glue->core) avoids both use-after-free paths. [ ... ] > + if (!cc) { > + dev_err(dev, "no cc33xx module was probed\n"); > + return -EINVAL; > + } [Severity: Medium] Should cc33xx_suspend() return 0 rather than -EINVAL when the child cc33xx platform driver is not bound? Returning -EINVAL aborts system-wide suspend whenever the separate cc33xx module is not loaded or was unbound, even though the card can safely be powered down (wlcore/sdio.c returns 0 in this case). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203070906.1294= 171-1-r-ramalingam@ti.com?part=3D4