From cf296ba80c7f51c90a739263505d9bcf6575a0f7 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 19 Jun 2009 16:32:26 +0000 Subject: [PATCH] Fix possible crash in scst_copy_sg() git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@914 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index e492c820b..08461f8f1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -2397,6 +2397,14 @@ void scst_copy_sg(struct scst_cmd *cmd, enum scst_sg_copy_dir copy_dir) "to_copy %d", cmd, copy_dir, src_sg, src_sg_cnt, dst_sg, to_copy); + if (unlikely(src_sg == NULL) || unlikely(dst_sg == NULL)) { + /* + * It can happened, e.g., with scst_user for cmd with delay + * alloc, which failed with Check Condition. + */ + goto out; + } + dst = sg_page(dst_sg); dst_len = dst_sg->length; dst_offs = dst_sg->offset;