From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755242AbbIHQXP (ORCPT ); Tue, 8 Sep 2015 12:23:15 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36836 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754697AbbIHQXM (ORCPT ); Tue, 8 Sep 2015 12:23:12 -0400 From: Sudip Mukherjee To: Oleg Drokin , Andreas Dilger , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, HPDD-discuss@ml01.01.org, devel@driverdev.osuosl.org, Sudip Mukherjee Subject: [PATCH 1/2] staging: lustre: lov: fix dereference of ERR_PTR Date: Tue, 8 Sep 2015 21:53:01 +0530 Message-Id: <1441729382-27865-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 bf36291..b5b2580 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); -- 1.9.1