{"id":"CVE-2022-48975","aliases":["CVE-2022-48975"],"related":[],"kind":"vulnerability","state":"published","title":"gpiolib: fix memory leak in gpiochip_setup_dev()","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\ngpiolib: fix memory leak in gpiochip_setup_dev()\n\nHere is a backtrace report about memory leak detected in\ngpiochip_setup_dev():\n\nunreferenced object 0xffff88810b406400 (size 512):\n  comm \"python3\", pid 1682, jiffies 4295346908 (age 24.090s)\n  backtrace:\n    kmalloc_trace\n    device_add\t\tdevice_private_init at drivers/base/core.c:3361\n\t\t\t(inlined by) device_add at drivers/base/core.c:3411\n    cdev_device_add\n    gpiolib_cdev_register\n    gpiochip_setup_dev\n    gpiochip_add_data_with_key\n\ngcdev_register() & gcdev_unregister() would call device_add() &\ndevice_del() (no matter CONFIG_GPIO_CDEV is enabled or not) to\nregister/unregister device.\n\nHowever, if device_add() succeeds, some resource (like\nstruct device_private allocated by device_private_init())\nis not released by device_del().\n\nTherefore, after device_add() succeeds by gcdev_register(), it\nneeds to call put_device() to release resource in the error handle\npath.\n\nHere we move forward the register of release function, and let it\nrelease every piece of resource by put_device() instead of kfree().\n\nWhile at it, fix another subtle issue, i.e. when gc->ngpio is equal\nto 0, we still call kcalloc() and, in case of further error, kfree()\non the ZERO_PTR pointer, which is not NULL. It's not a bug per se,\nbut rather waste of the resources and potentially wrong expectation\nabout contents of the gdev->descs variable.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\ngpiolib: fix memory leak in gpiochip_setup_dev()\n\nHere is a backtrace report about memory leak detected in\ngpiochip_setup_dev():\n\nunreferenced object 0xffff88810b406400 (size 512):\n  comm \"python3\", pid 1682, jiffies 4295346908 (age 24.090s)\n  backtrace:\n    kmalloc_trace\n    device_add\t\tdevice_private_init at drivers/base/core.c:3361\n\t\t\t(inlined by) device_add at drivers/base/core.c:3411\n    cdev_device_add\n    gpiolib_cdev_register\n    gpiochip_setup_dev\n    gpiochip_add_data_with_key\n\ngcdev_register() & gcdev_unregister() would call device_add() &\ndevice_del() (no matter CONFIG_GPIO_CDEV is enabled or not) to\nregister/unregister device.\n\nHowever, if device_add() succeeds, some resource (like\nstruct device_private allocated by device_private_init())\nis not released by device_del().\n\nTherefore, after device_add() succeeds by gcdev_register(), it\nneeds to call put_device() to release resource in the error handle\npath.\n\nHere we move forward the register of release function, and let it\nrelease every piece of resource by put_device() instead of kfree().\n\nWhile at it, fix another subtle issue, i.e. when gc->ngpio is equal\nto 0, we still call kcalloc() and, in case of further error, kfree()\non the ZERO_PTR pointer, which is not NULL. It's not a bug per se,\nbut rather waste of the resources and potentially wrong expectation\nabout contents of the gdev->descs variable.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: gpiolib: reparar pérdida de memoria en gpiochip_setup_dev() Aquí hay un informe de seguimiento sobre la pérdida de memoria detectada en gpiochip_setup_dev(): objeto sin referencia 0xffff88810b406400 (tamaño 512): comm \"python3\", pid 1682, jiffies 4295346908 (edad 24.090s) seguimiento: kmalloc_trace device_add device_private_init en drivers/base/core.c:3361 (en línea por) device_add en drivers/base/core.c:3411 cdev_device_add gpiolib_cdev_register gpiochip_setup_dev gpiochip_add_data_with_key gcdev_register() y gcdev_unregister() llamarían device_add() y device_del() (sin importar si CONFIG_GPIO_CDEV está habilitado o no) para registrar/anular el registro del dispositivo. Sin embargo, si device_add() tiene éxito, algún recurso (como la estructura device_private asignada por device_private_init()) no es liberado por device_del(). Por lo tanto, después de que device_add() tenga éxito por gcdev_register(), necesita llamar a put_device() para liberar el recurso en la ruta del controlador de error. Aquí avanzamos el registro de la función de liberación y dejamos que libere cada pieza de recurso por put_device() en lugar de kfree(). Mientras lo hacemos, solucionamos otro problema sutil, es decir, cuando gc-&gt;ngpio es igual a 0, todavía llamamos a kcalloc() y, en caso de un error adicional, a kfree() en el puntero ZERO_PTR, que no es NULL. No es un error en sí, sino más bien un desperdicio de recursos y una expectativa potencialmente errónea sobre el contenido de la variable gdev-&gt;descs.","source":"nvd"}],"published":"2024-10-21T20:05:55.091Z","modified":"2026-06-17T05:16:45.373Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"},"severities":[{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"}],"cwes":["CWE-401"],"affected":[{"ranges":[{"type":"git","introduced":"159f3cd92f17c61a4e2a47456de5865b114ef88e","fixed":"6daaa84b621485fe28c401be18debf92ae8ef04a","status":"affected"},{"type":"git","introduced":"159f3cd92f17c61a4e2a47456de5865b114ef88e","fixed":"371363716398ed718e389bea8c5e9843a79dde4e","status":"affected"},{"type":"git","introduced":"159f3cd92f17c61a4e2a47456de5865b114ef88e","fixed":"ec851b23084b3a0af8bf0f5e51d33a8d678bdc49","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"4.6","status":"affected"},{"type":"semver","introduced":"0","fixed":"4.6","status":"unaffected"},{"type":"semver","introduced":"5.15.83","lastAffected":"5.15.*","status":"unaffected"},{"type":"semver","introduced":"6.0.13","lastAffected":"6.0.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"4.6","fixed":"5.15.83"},{"status":"affected","introduced":"5.16","fixed":"6.0.13"},{"status":"affected","version":"6.1"},{"status":"affected","version":"6.1"},{"status":"affected","version":"6.1"},{"status":"affected","version":"6.1"},{"status":"affected","version":"6.1"},{"status":"affected","version":"6.1"},{"status":"affected","version":"6.1"},{"status":"affected","version":"6.1"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/6daaa84b621485fe28c401be18debf92ae8ef04a","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/371363716398ed718e389bea8c5e9843a79dde4e","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/ec851b23084b3a0af8bf0f5e51d33a8d678bdc49","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-10-22T13:18:35.922Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-48975","url":"https://www.cve.org/CVERecord?id=CVE-2022-48975","licence":"CVE Terms of Use","modified":"2026-05-11T18:50:46.796Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-48975","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-48975","licence":"Public domain","modified":"2026-06-17T05:16:45.373Z"}],"updatedAt":"2026-11-25T22:58:20.012Z","epss":{"score":0.00248,"percentile":0.17157,"date":"2026-12-02T12:00:21.000Z"}}