From patchwork Fri Oct 20 13:17:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Miller X-Patchwork-Id: 10020219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20702602CB for ; Fri, 20 Oct 2017 13:17:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10D4B28E78 for ; Fri, 20 Oct 2017 13:17:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05BCA28EE8; Fri, 20 Oct 2017 13:17:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2913B28E78 for ; Fri, 20 Oct 2017 13:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751776AbdJTNRa (ORCPT ); Fri, 20 Oct 2017 09:17:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45282 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751750AbdJTNR3 (ORCPT ); Fri, 20 Oct 2017 09:17:29 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9KDAQGS033437 for ; Fri, 20 Oct 2017 09:17:29 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dqfwq6d4u-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 20 Oct 2017 09:17:29 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Oct 2017 09:17:28 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Oct 2017 09:17:25 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9KDHP7n40829162; Fri, 20 Oct 2017 13:17:25 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 873AF112051; Fri, 20 Oct 2017 09:16:57 -0400 (EDT) Received: from oc5780617838.ibm.com (unknown [9.80.111.105]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 432D6112040; Fri, 20 Oct 2017 09:16:57 -0400 (EDT) From: Douglas Miller To: linux-scsi@vger.kernel.org Cc: qla2xxx-upstream@qlogic.com Subject: [PATCH 1/1] qla2xxx: Fix oops in qla2x00_probe_one error path Date: Fri, 20 Oct 2017 08:17:22 -0500 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1508505442-30352-1-git-send-email-dougmill@linux.vnet.ibm.com> References: <1508505442-30352-1-git-send-email-dougmill@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17102013-0044-0000-0000-000003A29030 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007923; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00933865; UDB=6.00470413; IPR=6.00714153; BA=6.00005651; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017624; XFM=3.00000015; UTC=2017-10-20 13:17:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102013-0045-0000-0000-000007D198F0 Message-Id: <1508505442-30352-2-git-send-email-dougmill@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-20_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710200186 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On error, kthread_create() returns an errno-encoded pointer, not NULL. The routine qla2x00_probe_one() detects the error case and jumps to probe_failed, but has already assigned the return value from kthread_create() to ha->dpc_thread. Then probe_failed checks to see if ha->dpc_thread is not NULL before doing cleanup on it. Since in the error case this is also not NULL, it ends up trying to access an invalid task pointer. Solution is to assign NULL to ha->dpc_thread in the error path to avoid kthread cleanup in that case. Signed-off-by: Douglas Miller Acked-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_os.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 9372098..bd39bf2 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3212,6 +3212,7 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) ql_log(ql_log_fatal, base_vha, 0x00ed, "Failed to start DPC thread.\n"); ret = PTR_ERR(ha->dpc_thread); + ha->dpc_thread = NULL; goto probe_failed; } ql_dbg(ql_dbg_init, base_vha, 0x00ee,