From patchwork Mon Jul 4 16:26:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland Dreier X-Patchwork-Id: 942452 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p64GR55m030597 for ; Mon, 4 Jul 2011 16:27:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758284Ab1GDQ1E (ORCPT ); Mon, 4 Jul 2011 12:27:04 -0400 Received: from na3sys010aog110.obsmtp.com ([74.125.245.88]:52430 "HELO na3sys010aog110.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1758293Ab1GDQ1D (ORCPT ); Mon, 4 Jul 2011 12:27:03 -0400 Received: from mail-pz0-f54.google.com ([209.85.210.54]) (using TLSv1) by na3sys010aob110.postini.com ([74.125.244.12]) with SMTP ID DSNKThHp1grs3BvXPHkrElb/HNoir4WAYlu0@postini.com; Mon, 04 Jul 2011 09:27:03 PDT Received: by mail-pz0-f54.google.com with SMTP id 27so3226269pzk.13 for ; Mon, 04 Jul 2011 09:27:02 -0700 (PDT) Received: by 10.68.30.198 with SMTP id u6mr7429463pbh.451.1309796822476; Mon, 04 Jul 2011 09:27:02 -0700 (PDT) Received: from localhost.localdomain (c-69-181-166-205.hsd1.ca.comcast.net [69.181.166.205]) by mx.google.com with ESMTPS id m7sm3925313pbk.6.2011.07.04.09.27.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 04 Jul 2011 09:27:01 -0700 (PDT) From: Roland Dreier To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Subject: RDMA: Check for NULL mode in .devnode methods Date: Mon, 4 Jul 2011 09:26:57 -0700 Message-Id: <1309796817-25293-1-git-send-email-roland@kernel.org> X-Mailer: git-send-email 1.7.5.4 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 04 Jul 2011 16:27:05 +0000 (UTC) From: Goldwyn Rodrigues Commits 71c29bd5c235 ("IB/uverbs: Add devnode method to set path/mode") and c3af0980ce01 ("IB: Add devnode methods to cm_class and umad_class") added devnode methods that set the mode. However, these methods don't check for a NULL mode, and so we get a crash when unloading modules because devtmpfs_delete_node() calls device_get_devnode() with mode == NULL. Add the missing checks. Signed-off-by: Goldwyn Rodrigues [ Also fix cm.c. - Roland ] Signed-off-by: Roland Dreier --- Linus, please apply -- this fixes a regression introduced in 3.0-rc1. drivers/infiniband/core/cm.c | 3 ++- drivers/infiniband/core/uverbs_main.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index f62f52f..fc0f2bd 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -3641,7 +3641,8 @@ static struct kobj_type cm_port_obj_type = { static char *cm_devnode(struct device *dev, mode_t *mode) { - *mode = 0666; + if (mode) + *mode = 0666; return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev)); } diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index e49a85f..56898b6 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -826,7 +826,8 @@ static void ib_uverbs_remove_one(struct ib_device *device) static char *uverbs_devnode(struct device *dev, mode_t *mode) { - *mode = 0666; + if (mode) + *mode = 0666; return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev)); }