]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
EDAC/mc: Fix edac_mc_find() in case no device is found
authorRobert Richter <rrichter@marvell.com>
Tue, 14 May 2019 10:49:09 +0000 (10:49 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
commit6e410298c9818f7dedd5aa83aeeb8d640e47583a
tree9f7bf71e75acdb0bc30afe8f84ac251dab8e8e1f
parenteb2c9a5e5c4d8a453d1d69e91ab7128af659ef31
EDAC/mc: Fix edac_mc_find() in case no device is found

BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit 29a0c843973bc385918158c6976e4dbe891df969 ]

The function should return NULL in case no device is found, but it
always returns the last checked mc device from the list even if the
index did not match. Fix that.

I did some analysis why this did not raise any issues for about 3 years
and the reason is that edac_mc_find() is mostly used to search for
existing devices. Thus, the bug is not triggered.

 [ bp: Drop the if (mci->mc_idx > idx) test in favor of readability. ]

Fixes: c73e8833bec5 ("EDAC, mc: Fix locking around mc_devices list")
Signed-off-by: Robert Richter <rrichter@marvell.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>
Cc: James Morse <james.morse@arm.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lkml.kernel.org/r/20190514104838.15065-1-rrichter@marvell.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/edac/edac_mc.c