overflow.h: Add arithmetic shift helper
authorJason Gunthorpe <jgg@mellanox.com>
Wed, 1 Aug 2018 21:25:39 +0000 (14:25 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 2 May 2020 15:24:21 +0000 (17:24 +0200)
commit334c43f8d69fa5aa6487157b927ed9146e40786e
treed79fbc9d56d513033a58472864a61ae18015fc07
parent17f673a9861cb15b98fcae1467647d7817e46109
overflow.h: Add arithmetic shift helper

commit 0c66847793d1982d1083dc6f7adad60fa265ce9c upstream.

Add shift_overflow() helper to assist driver authors in ensuring that
shift operations don't cause overflows or other odd conditions.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
[kees: tweaked comments and commit log, dropped unneeded assignment]
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/overflow.h