{"id":"CVE-2026-31732","state":"PUBLISHED","title":"gpio: Fix resource leaks on errors in gpiochip_add_data_with_key()","description":"In the Linux kernel, the following vulnerability has been resolved:\n\ngpio: Fix resource leaks on errors in gpiochip_add_data_with_key()\n\nSince commit aab5c6f20023 (\"gpio: set device type for GPIO chips\"),\n`gdev->dev.release` is unset.  As a result, the reference count to\n`gdev->dev` isn't dropped on the error handling paths.\n\nDrop the reference on errors.\n\nAlso reorder the instructions to make the error handling simpler.\nNow gpiochip_add_data_with_key() roughly looks like:\n\n   >>> Some memory allocation.  Go to ERR ZONE 1 on errors.\n   >>> device_initialize().\n\n   gpiodev_release() takes over the responsibility for freeing the\n   resources of `gdev->dev`.  The subsequent error handling paths\n   shouldn't go through ERR ZONE 1 again which leads to double free.\n\n   >>> Some initialization mainly on `gdev`.\n   >>> The rest of initialization.  Go to ERR ZONE 2 on errors.\n   >>> Chip registration success and exit.\n\n   >>> ERR ZONE 2.  gpio_device_put() and exit.\n   >>> ERR ZONE 1.","publishedAt":"2026-05-01T14:14:30.844Z","updatedAt":"2026-07-04T11:50:32.706Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"aab5c6f200238ac45001bec3d5494fff8438a8dc","status":"affected","lessThan":"a500e1837c4266ddb05b39b3e1cc71f49a43ffa5","versionType":"git"},{"version":"aab5c6f200238ac45001bec3d5494fff8438a8dc","status":"affected","lessThan":"f0cf9c7b7c281956cc0dec163132cd96f76e1d60","versionType":"git"},{"version":"aab5c6f200238ac45001bec3d5494fff8438a8dc","status":"affected","lessThan":"fb4584d2b324c522404c733c65840a1a6519ada8","versionType":"git"},{"version":"aab5c6f200238ac45001bec3d5494fff8438a8dc","status":"affected","lessThan":"16fdabe143fce2cbf89139677728e17e21b46c28","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/gpio/gpiolib.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.9","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.9","versionType":"semver"},{"version":"6.12.95","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.22","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"6.19.12","status":"unaffected","lessThanOrEqual":"6.19.*","versionType":"semver"},{"version":"7.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/gpio/gpiolib.c"]}],"references":["https://git.kernel.org/stable/c/a500e1837c4266ddb05b39b3e1cc71f49a43ffa5","https://git.kernel.org/stable/c/f0cf9c7b7c281956cc0dec163132cd96f76e1d60","https://git.kernel.org/stable/c/fb4584d2b324c522404c733c65840a1a6519ada8","https://git.kernel.org/stable/c/16fdabe143fce2cbf89139677728e17e21b46c28"],"weaknesses":[],"ingestedAt":"2026-10-29T20:11:40.391Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/31xxx/CVE-2026-31732.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-31732","state":"PUBLISHED","datePublished":"2026-05-01T14:14:30.844Z","dateUpdated":"2026-07-04T11:50:32.706Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-03-09T15:48:24.137Z"},"containers":{"cna":{"title":"gpio: Fix resource leaks on errors in gpiochip_add_data_with_key()","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\ngpio: Fix resource leaks on errors in gpiochip_add_data_with_key()\n\nSince commit aab5c6f20023 (\"gpio: set device type for GPIO chips\"),\n`gdev->dev.release` is unset.  As a result, the reference count to\n`gdev->dev` isn't dropped on the error handling paths.\n\nDrop the reference on errors.\n\nAlso reorder the instructions to make the error handling simpler.\nNow gpiochip_add_data_with_key() roughly looks like:\n\n   >>> Some memory allocation.  Go to ERR ZONE 1 on errors.\n   >>> device_initialize().\n\n   gpiodev_release() takes over the responsibility for freeing the\n   resources of `gdev->dev`.  The subsequent error handling paths\n   shouldn't go through ERR ZONE 1 again which leads to double free.\n\n   >>> Some initialization mainly on `gdev`.\n   >>> The rest of initialization.  Go to ERR ZONE 2 on errors.\n   >>> Chip registration success and exit.\n\n   >>> ERR ZONE 2.  gpio_device_put() and exit.\n   >>> ERR ZONE 1."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"aab5c6f200238ac45001bec3d5494fff8438a8dc","status":"affected","lessThan":"a500e1837c4266ddb05b39b3e1cc71f49a43ffa5","versionType":"git"},{"version":"aab5c6f200238ac45001bec3d5494fff8438a8dc","status":"affected","lessThan":"f0cf9c7b7c281956cc0dec163132cd96f76e1d60","versionType":"git"},{"version":"aab5c6f200238ac45001bec3d5494fff8438a8dc","status":"affected","lessThan":"fb4584d2b324c522404c733c65840a1a6519ada8","versionType":"git"},{"version":"aab5c6f200238ac45001bec3d5494fff8438a8dc","status":"affected","lessThan":"16fdabe143fce2cbf89139677728e17e21b46c28","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/gpio/gpiolib.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.9","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.9","versionType":"semver"},{"version":"6.12.95","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.22","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"6.19.12","status":"unaffected","lessThanOrEqual":"6.19.*","versionType":"semver"},{"version":"7.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/gpio/gpiolib.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/a500e1837c4266ddb05b39b3e1cc71f49a43ffa5"},{"url":"https://git.kernel.org/stable/c/f0cf9c7b7c281956cc0dec163132cd96f76e1d60"},{"url":"https://git.kernel.org/stable/c/fb4584d2b324c522404c733c65840a1a6519ada8"},{"url":"https://git.kernel.org/stable/c/16fdabe143fce2cbf89139677728e17e21b46c28"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-07-04T11:50:32.706Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.9","versionEndExcluding":"6.12.95"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.9","versionEndExcluding":"6.18.22"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.9","versionEndExcluding":"6.19.12"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.9","versionEndExcluding":"7.0"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}