]> git.baikalelectronics.ru Git - kernel.git/commit
NTB: EPF: Tidy up some bounds checks
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 1 Aug 2022 10:17:32 +0000 (13:17 +0300)
committerJon Mason <jdmason@kudzu.us>
Tue, 9 Aug 2022 21:54:54 +0000 (17:54 -0400)
commit33da01631af9672543a7734af3b3d0f9c90d2588
tree54583160357f03fbbf67e955eaa3561fd69e6598
parent550fce5a13df034f1c3f0af2d250314ba023c2dc
NTB: EPF: Tidy up some bounds checks

This sscanf() is reading from the filename which was set by the kernel
so it should be trust worthy.  Although the data is likely trust worthy
there is some bounds checking but unfortunately, it is not complete or
consistent.  Additionally, the Smatch static checker marks everything
that comes from sscanf() as tainted and so Smatch complains that this
code can lead to an out of bounds issue.  Let's clean things up and make
Smatch happy.

The first problem is that there is no bounds checking in the _show()
functions.  The _store() and _show() functions are very similar so make
the bounds checking the same in both.

The second issue is that if "win_no" is zero it leads to an array
underflow so add an if (win_no <= 0) check for that.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Souptick Joarder (HPE) <jrdr.linux@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
drivers/pci/endpoint/functions/pci-epf-vntb.c