{"id":"CVE-2021-47195","state":"PUBLISHED","title":"spi: fix use-after-free of the add_lock mutex","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nspi: fix use-after-free of the add_lock mutex\n\nCommit 6098475d4cb4 (\"spi: Fix deadlock when adding SPI controllers on\nSPI buses\") introduced a per-controller mutex. But mutex_unlock() of\nsaid lock is called after the controller is already freed:\n\n  spi_unregister_controller(ctlr)\n  -> put_device(&ctlr->dev)\n    -> spi_controller_release(dev)\n  -> mutex_unlock(&ctrl->add_lock)\n\nMove the put_device() after the mutex_unlock().","publishedAt":"2024-04-10T18:56:31.999Z","updatedAt":"2026-05-23T15:19:30.977Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"aa3f3d7bef59583f2d3234173105a27ff61ef8fe","status":"affected","lessThan":"54c2c96eafcfd242e52e932ab54ace4784efe1dd","versionType":"git"},{"version":"c8dce228db6f81dbc897a018dfc5c418e917cf64","status":"affected","lessThan":"11eab327a2a8bd36c38afbff920ae1bd45588dd4","versionType":"git"},{"version":"6098475d4cb48d821bdf453c61118c56e26294f0","status":"affected","lessThan":"37330f37f6666c7739a44b2b6b95b047ccdbed2d","versionType":"git"},{"version":"6098475d4cb48d821bdf453c61118c56e26294f0","status":"affected","lessThan":"6c53b45c71b4920b5e62f0ea8079a1da382b9434","versionType":"git"},{"version":"722ef19a161ce3fffb3d1b01ce2301c306639bdd","status":"affected","versionType":"git"},{"version":"5.14.15","status":"affected","lessThan":"5.15","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/spi/spi.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.15","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.15","versionType":"semver"},{"version":"5.15.5","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"5.16","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/spi/spi.c"]}],"references":["https://git.kernel.org/stable/c/54c2c96eafcfd242e52e932ab54ace4784efe1dd","https://git.kernel.org/stable/c/11eab327a2a8bd36c38afbff920ae1bd45588dd4","https://git.kernel.org/stable/c/37330f37f6666c7739a44b2b6b95b047ccdbed2d","https://git.kernel.org/stable/c/6c53b45c71b4920b5e62f0ea8079a1da382b9434"],"weaknesses":[],"ingestedAt":"2026-10-29T19:49:19.404Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2021/47xxx/CVE-2021-47195.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2021-47195","state":"PUBLISHED","datePublished":"2024-04-10T18:56:31.999Z","dateUpdated":"2026-05-23T15:19:30.977Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2024-03-25T09:12:14.114Z"},"containers":{"cna":{"title":"spi: fix use-after-free of the add_lock mutex","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nspi: fix use-after-free of the add_lock mutex\n\nCommit 6098475d4cb4 (\"spi: Fix deadlock when adding SPI controllers on\nSPI buses\") introduced a per-controller mutex. But mutex_unlock() of\nsaid lock is called after the controller is already freed:\n\n  spi_unregister_controller(ctlr)\n  -> put_device(&ctlr->dev)\n    -> spi_controller_release(dev)\n  -> mutex_unlock(&ctrl->add_lock)\n\nMove the put_device() after the mutex_unlock()."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"aa3f3d7bef59583f2d3234173105a27ff61ef8fe","status":"affected","lessThan":"54c2c96eafcfd242e52e932ab54ace4784efe1dd","versionType":"git"},{"version":"c8dce228db6f81dbc897a018dfc5c418e917cf64","status":"affected","lessThan":"11eab327a2a8bd36c38afbff920ae1bd45588dd4","versionType":"git"},{"version":"6098475d4cb48d821bdf453c61118c56e26294f0","status":"affected","lessThan":"37330f37f6666c7739a44b2b6b95b047ccdbed2d","versionType":"git"},{"version":"6098475d4cb48d821bdf453c61118c56e26294f0","status":"affected","lessThan":"6c53b45c71b4920b5e62f0ea8079a1da382b9434","versionType":"git"},{"version":"722ef19a161ce3fffb3d1b01ce2301c306639bdd","status":"affected","versionType":"git"},{"version":"5.14.15","status":"affected","lessThan":"5.15","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/spi/spi.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.15","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.15","versionType":"semver"},{"version":"5.15.5","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"5.16","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/spi/spi.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/54c2c96eafcfd242e52e932ab54ace4784efe1dd"},{"url":"https://git.kernel.org/stable/c/11eab327a2a8bd36c38afbff920ae1bd45588dd4"},{"url":"https://git.kernel.org/stable/c/37330f37f6666c7739a44b2b6b95b047ccdbed2d"},{"url":"https://git.kernel.org/stable/c/6c53b45c71b4920b5e62f0ea8079a1da382b9434"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-05-23T15:19:30.977Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.15","versionEndExcluding":"5.15.5"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.15","versionEndExcluding":"5.16"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.14.15"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2021-47195","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"partial"}],"version":"2.0.3","timestamp":"2024-04-10T19:52:25.727067Z"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2024-06-04T17:13:36.222Z"}},{"title":"CVE Program Container","references":[{"url":"https://git.kernel.org/stable/c/37330f37f6666c7739a44b2b6b95b047ccdbed2d","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/6c53b45c71b4920b5e62f0ea8079a1da382b9434","tags":["x_transferred"]}],"providerMetadata":{"shortName":"CVE","orgId":"af854a3a-2127-422b-91ae-364da2661108","dateUpdated":"2024-08-04T05:32:07.110Z"}}]}}}