Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp837912img; Mon, 18 Mar 2019 15:46:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOJasaMfoE6lMaRCkAx1NnPoG4UM2/Fqs5EoKy+hyrkV1i4oavtcdJjBqRTiZJ6kjTIvB6 X-Received: by 2002:a62:4649:: with SMTP id t70mr3873304pfa.100.1552949174214; Mon, 18 Mar 2019 15:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552949174; cv=none; d=google.com; s=arc-20160816; b=c7Rn0z6MTszNMjRgZoNAOCpLCTLYY8rqVd1cIYMbUQtkcuLO7KZmKSdKuJOyS6dR6a P+IBKnxYBZGsv7n8gWKqc9y7mf1M2QkaR0CVCE/XmkCZ5E2cvzxjj+viebCMoiTtuOXK XNMOCNUBmNWEtV+jGYAUcIKmFc7iR5iYiaE4NVwuTwBNrz6j+NXajxpc/XXpIy9jq8QY CrVUxt6gD+dTtbDdifFfiM3xBdqucJCkSx1ejhMVGQjSKqpwctDVLqLirZKAuT8gXS3L /HlcWnBx0XDtdcM59LBTo1ARBV1wHbNz7oH7AKBYrliFZhr2wpE3MXVPm7bn9xUMETMt sHQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language:thread-index :content-transfer-encoding:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from:dkim-signature; bh=iLqHCSLsLvKuQmQ3KuSNufoEe0+TFmNnyPuUfZN4AXs=; b=p40pQkyoZonI2+bLJ93+RWFv8RLCoOZBSC6ZcxfTZMOegJNmwkqoGDDi22nr9S3qjM WK5QiXHPbZWVNGmica2Owfmr+nQ/hNcK7ook63qsVh9Aj8q0sz6FR63YKnf+tlt4JmUF 9PjN2OWc+XqqNbpTrvBLwbmNZERN9qrdac4ZdNHHPv5lrVGwbf3yidNsxfvhTz18+g4P 4+8Xfaol0gRnyY8dUBoFbgq8Bcl7/wyPy0vUHCFqFlmQ8Fd0JNZgBybrEf8CFf+9dLI+ pDXZeFPj53BCHMz+v6WMJXbUeltomPYgE4TtvA9RmVRSF3DC0EPiarxu3/p/zkG+2Ntj 5m0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r7GDNxkw; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si10837215pln.403.2019.03.18.15.45.59; Mon, 18 Mar 2019 15:46:14 -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=@gmail.com header.s=20161025 header.b=r7GDNxkw; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726983AbfCRWoJ (ORCPT + 99 others); Mon, 18 Mar 2019 18:44:09 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:32992 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbfCRWoI (ORCPT ); Mon, 18 Mar 2019 18:44:08 -0400 Received: by mail-it1-f195.google.com with SMTP id f186so17846098ita.0 for ; Mon, 18 Mar 2019 15:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:thread-index :content-language; bh=iLqHCSLsLvKuQmQ3KuSNufoEe0+TFmNnyPuUfZN4AXs=; b=r7GDNxkwGzHvhd2Toy7SFyuUWXSwIlWi9mJVvy6oIZMzVecOkTEJVTuhGqFZAQl9hc Afc65WCDJrwK6UGBH7AaUJX+UwYE7gCwon2KH6R8rDlsjVix0pYiFOpiu9xAVSjDnzKt 62JORpzWI2eJ4rgg+O+kc5/v6GAXrQOJKXmlC7A46OTogRn6C/2Kt6YlLWbMklCM5Sj3 BFgxqkdRTzVErfLfPp0IU/pyX64L9ArmPrZ3SUxYPILok7Krb6FGXGiVHaxpwKKwZjel M9LIZjwLS8JkqTrBPJqMDrH7QZWxkOnKhXzeumAtzr7pG+fgKs0AQg5GpRuIctYqfgym y4bw== 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:references:in-reply-to:subject:date :message-id:mime-version:content-transfer-encoding:thread-index :content-language; bh=iLqHCSLsLvKuQmQ3KuSNufoEe0+TFmNnyPuUfZN4AXs=; b=CygTLDjMfboce5g2dUrvwpQVEE/QZJlt4zLO+5tMelzcs6lVAAkOPDa3fbuZO75tXQ QiG58HQRcvpDyz71eqaUTQNqJptSrIOU92FT/3svTlv2SdOxDFW7VN8LblZ0PmD1XB5J pLfuYA5w6QuOY6ccqW2jCUZ6nAJQE7x8yoZnf1QEyFNGn5l3xaLMZsdaAeM7zOpsb1jK C4kiyJAtihEIX61+vadxQWSuBP0FdjYKPKQAveh5lFoEfbZgKWBZxTcXQthBSH/IwlSA Z/gsXbp8fbp1rTpqaFp7bONdQQOTqnR0dUOt2LmTZJDwuX6HbmpOjKhn2IIz96y96x1J XqaQ== X-Gm-Message-State: APjAAAW2BcGMwCWvcF0S3b/U5KCCrn1G0/g8y0yQd5KYSWWUx1WBxAKJ TwnnueGmNy+sUxV6IGFwTec= X-Received: by 2002:a24:ddc6:: with SMTP id t189mr864817itf.30.1552949047673; Mon, 18 Mar 2019 15:44:07 -0700 (PDT) Received: from AlexPC (CPEac9e17937810-CM64777dd8e660.cpe.net.cable.rogers.com. [174.112.89.107]) by smtp.gmail.com with ESMTPSA id g64sm388485itg.44.2019.03.18.15.44.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 15:44:06 -0700 (PDT) From: To: "'Kangjie Lu'" Cc: , "'Matt Porter'" , , References: <20190314061015.11291-1-kjlu@umn.edu> In-Reply-To: <20190314061015.11291-1-kjlu@umn.edu> Subject: RE: [PATCH] rapidio: fix a NULL pointer derefenrece when create_workqueue fails Date: Mon, 18 Mar 2019 18:44:05 -0400 Message-ID: <002101d4dddc$183d9660$48b8c320$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQN4sco7z0aobyYW9FNRQRf9ZboAuKLKVDvA Content-Language: en-us Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Acked-by: Alexandre Bounine -----Original Message----- From: Kangjie Lu Sent: Thursday, March 14, 2019 2:10 AM 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 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