Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3556310imc; Wed, 13 Mar 2019 23:11:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCZV8C9TVOOrTXyyMA/b2slqFES3aibfoVBoZWhfX5LnEKkUbI39I1sUHb4sBKpR7Ej7zD X-Received: by 2002:a17:902:6804:: with SMTP id h4mr49546897plk.115.1552543881352; Wed, 13 Mar 2019 23:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552543881; cv=none; d=google.com; s=arc-20160816; b=j3ublwk/QodSc7idVk7CCEymfdwjIH0imTDhBMGe5aI0zcP7i2iacPe21vcOY3/f0K +VoFmW5GEgeLVJOJYbr0/ERF/uUNVZYCnCGx/owmS+XOwstg7+7vMM2yu9BjTrfIw1pd xvApzAvqpNbhqYQwfslJ80h7QjPt7ZpXZCt4AXNz4IOQ2ngXsT1CfmjmKXFP0yM79K4H vQf6XpVmDgmfSI8YXaqCOCFQmy/mxHoyLx4beaECRpnEkEABtyd+PrRrON4ZgkVtzZus aBfl8sUDt3H0LpCyCR6pUrnQDarx2qb1shyRxwu5zVbC3cZ2wP04Z3VCLkxsZqMPzvjF aJqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=K6nd7rHuf5jkq4Vkom/yzCR+WfV8SUCoSAXMWbiPRCk=; b=Qy0P0e1gG9Qcj2CgYTtXu8jIUaSmPVNfzFB80qxVuvb+RhfvIv2WZBTYdDymK0ozTi hQtl2uLX7Z7RAk6q72wlatImdPGZIOEEUuTan+4eilYHoUhkdbSB1kf6Gw4Yp9R9GJQZ x7RLXwHIKEIynvthKOuDC/Z4qOTIri04pnFs7l90Flvuk/lJazCo7ZpC55OvO4umSu9s tbbW+G32q1nLtMhPql7j2bo4S4XHXz6BK2lfjwlNPXk4ugoG/z97oEdwk7tirNonaZDw 1sDF4Fqkd9hV6P8fDjtuR3OwhGKcGkKs2gGqGL3HdqT2upypW6jVQw1B/M62VVcMWGYC wa4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b="fQ50pq/m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g75si12634005pfg.49.2019.03.13.23.11.06; Wed, 13 Mar 2019 23:11:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b="fQ50pq/m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbfCNGK3 (ORCPT + 99 others); Thu, 14 Mar 2019 02:10:29 -0400 Received: from mta-p6.oit.umn.edu ([134.84.196.206]:41582 "EHLO mta-p6.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbfCNGK3 (ORCPT ); Thu, 14 Mar 2019 02:10:29 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id D3326C3B for ; Thu, 14 Mar 2019 06:10:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6OpQg2sMzHPh for ; Thu, 14 Mar 2019 01:10:27 -0500 (CDT) Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p6.oit.umn.edu (Postfix) with ESMTPS id AAA52C01 for ; Thu, 14 Mar 2019 01:10:27 -0500 (CDT) Received: by mail-io1-f71.google.com with SMTP id r21so3472578iod.12 for ; Wed, 13 Mar 2019 23:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=K6nd7rHuf5jkq4Vkom/yzCR+WfV8SUCoSAXMWbiPRCk=; b=fQ50pq/mAoJhRZBxW1WT/+kkqv72QiPbRCKOHrcxfifAnqdC2eGsOMGWrj0AbfCGyp O3fp/mwPY4GoJJ3tToSbRtWkqWkwqJrZD2AH/0hfUAEV2exJzMaSvlXO1rUDqPoB9P8Q dAF0R+wnM5KY8I5LO/z4xUxm4ZeGVNytwiiM+aQhj8VAJ1JLgwcAtx98OFfDH1aRZls5 rlmnHUJRvpbln6nMB5ILfaQGZGD41PB9UJucFPUDlg9zOH9603Fs4Nxr/jiUE4x7y2R2 YHZIr+25Dqi1z6X1WcXViolxhbR+ed9bhwdJl0fxGRTENuZdZ1I2b60W9xXJMiqvxf3z fSjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K6nd7rHuf5jkq4Vkom/yzCR+WfV8SUCoSAXMWbiPRCk=; b=GbjNVOW5LmpJRKbPeMX1Cui4J6yH0i6Fp0hdOf5G+XgRCxyT7vm9ShWyBlQ9x1kINe Fy/o+7lxoeboaYZCcEuTetC0WCnkgRoRh9K9qvD7EUx1TxDTLNXC9hPbHN34cm0Ftuc0 vVjp9enJ/fRa2eOxr7toaXHU7rRv7AnTgxTZ9CbGgPmNbiKBEb0mwi66QMYDxpvCwWAc mNCTLE8cMMzCeLFjc1HOYoN/R3MRmbdA82kTkm5MWWcqvhOrk3VMu6UpJ9fcT8+g1OII CWHW38Kz2ngbh2awjo4Q4RhGmn093g6XToHUAd4CpFnRZJIZYV6bCnXiV1DN3icY75Dc hjrQ== X-Gm-Message-State: APjAAAU7ZSUK12aepRjIC+SxdEZtc/5pPMTLE2zowSMFwZuOfTSlSJWM ZMH5aTLLMO0bqVfSykIc/V57XjjMI0BQ5ENTvXybU19za5YIBOEufVmW6Od7O4wHs1Sj/Jtf3iw GaIUGpTpXhToSAjuCWmIzJYHjbn+n X-Received: by 2002:a24:908:: with SMTP id 8mr1041866itm.155.1552543827053; Wed, 13 Mar 2019 23:10:27 -0700 (PDT) X-Received: by 2002:a24:908:: with SMTP id 8mr1041854itm.155.1552543826824; Wed, 13 Mar 2019 23:10:26 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id l11sm6110763ion.52.2019.03.13.23.10.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:10:25 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Matt Porter , Alexandre Bounine , linux-kernel@vger.kernel.org Subject: [PATCH] rapidio: fix a NULL pointer derefenrece when create_workqueue fails Date: Thu, 14 Mar 2019 01:10:15 -0500 Message-Id: <20190314061015.11291-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case create_workqueue fails, the fix releases resources and returns -ENOMEM to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu --- drivers/rapidio/rio_cm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/rapidio/rio_cm.c b/drivers/rapidio/rio_cm.c index cf45829585cb..b29fc258eeba 100644 --- a/drivers/rapidio/rio_cm.c +++ b/drivers/rapidio/rio_cm.c @@ -2147,6 +2147,14 @@ static int riocm_add_mport(struct device *dev, mutex_init(&cm->rx_lock); riocm_rx_fill(cm, RIOCM_RX_RING_SIZE); cm->rx_wq = create_workqueue(DRV_NAME "/rxq"); + if (!cm->rx_wq) { + riocm_error("failed to allocate IBMBOX_%d on %s", + cmbox, mport->name); + rio_release_outb_mbox(mport, cmbox); + kfree(cm); + return -ENOMEM; + } + INIT_WORK(&cm->rx_work, rio_ibmsg_handler); cm->tx_slot = 0; -- 2.17.1