]> git.baikalelectronics.ru Git - 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)
committerBorislav Petkov <bp@suse.de>
Tue, 14 May 2019 15:08:46 +0000 (17:08 +0200)
commit90264cbaa12cb72636e98d9e8e2d7583da4e2f9a
tree9f3990e8980c93621c9a3d4c93616cd9c37667c8
parentb7056bc294353787917e251a82880413c284368e
EDAC/mc: Fix edac_mc_find() in case no device is found

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: c3144bd7b494 ("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
drivers/edac/edac_mc.c