staging: lustre: lov: fix dereference of ERR_PTR

This change “staging: lustre: lov: fix dereference of ERR_PTR” (commit d0f69b5) in Linux kernel is authored by Sudip Mukherjee <sudipm.mukherjee [at] gmail.com> on Tue Sep 8 21:53:01 2015 +0530.

Description of "staging: lustre: lov: fix dereference of ERR_PTR"

The change “staging: lustre: lov: fix dereference of ERR_PTR” introduces changes as follows.

staging: lustre: lov: fix dereference of ERR_PTR

If lov_sub_get() fails then it returns the error code in ERR_PTR, but
here we were dereferencing sub without checking if lov_sub_get() has
actually succeeded or not. And on error we can directly return the error
code from lov_io_fault_start() as it return 0 on success and the error
code on error.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Linux kernel releases containing commit d0f69b5

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "staging: lustre: lov: fix dereference of ERR_PTR"

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/staging/lustre/lustre/lov/lov_io.c | 2 ++
 1 file changed, 2 insertions(+)
 
diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c
index bf3629151d68..b5b25803d4f1 100644
--- a/drivers/staging/lustre/lustre/lov/lov_io.c
+++ b/drivers/staging/lustre/lustre/lov/lov_io.c
@@ -729,6 +729,8 @@ static int lov_io_fault_start(const struct lu_env *env,
 	fio = &ios->cis_io->u.ci_fault;
 	lio = cl2lov_io(env, ios);
 	sub = lov_sub_get(env, lio, lov_page_stripe(fio->ft_page));
+	if (IS_ERR(sub))
+		return PTR_ERR(sub);
 	sub->sub_io->u.ci_fault.ft_nob = fio->ft_nob;
 	lov_sub_put(sub);
 	return lov_io_start(env, ios);

The commit for this change in Linux stable tree is d0f69b5 (patch).

Last modified: 2020/02/09