Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3789164imm; Mon, 11 Jun 2018 01:37:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIKzmQ1ioc+tH9c2esN5Ih691y6v3rzlVGxm74wJXGXNKFpgF/M+2g0CZrQnyyPHOwCtZFe X-Received: by 2002:a17:902:7898:: with SMTP id q24-v6mr17566405pll.254.1528706251615; Mon, 11 Jun 2018 01:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528706251; cv=none; d=google.com; s=arc-20160816; b=EOB0xECp/GZtVfJV1BEIlCq3m7HG7LJTxv7JvSxogKFLfuVq6Y/e3Z22dAQzJVu5DH xFq6xfS4oP2xqVBjKuKriCrV9weEfon9cK4ohDCYdVyF8kuaT58Ttk0c255ZJgfGLNWF pH0wkE0T62IQGGgm1zYIZZQueLMNQFyH40+OFTM9VMUjFMjOM1STIO8F1NQe4/O6PHge 4MTU1dAXPBnnFZhQ00F6sWjKOdV3wS9YSxz9HSl2z7UK6eCgy6OARRwoJiJ14fzmHr6E maWoOAdM09DHOl58p56oPs7Kjs6ZvU2Ym0ty3GKnhQ1rsTpuuPd5Lg3iTFY467UxQTbZ M2HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=FTG8gJcA3AxjC8olL8p2LVHe6D4TEDxeNdhHMYDuNuc=; b=tEnm1DpcBo4FOlk2TWOiJsrP30zfYOIcRPDLtmlIM207ft7SM+GlTZ0uFIkM4IU+ZW 4kAejGn5wtwC0Y/Oe1A/TSAfREb5OjzQbNE+iJoGjc0X6TKKKTMsR0UNM4VmdwsEBR6A 2HmgZBFj+IAl4QAzlo95CilqWptCLabg/cqPgbH50OwkluRe8N7mfXVRLnXBvi+Fwzx4 +ckoWaXzadCJaQjGgVA920/JEoaIQPTMe2eXg9nG4L0q3ZxejWQLefqpIXdFwmmLoIBC vbeFnTlhmNoV02r2nFsF2YICrcx8vrEVnRXTnLroAtI2ZDNDq7/BtFf/syTtEh4gteF4 Xi8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jylQT2nv; 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=fail (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 b26-v6si23600726pff.278.2018.06.11.01.37.16; Mon, 11 Jun 2018 01:37:31 -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=fail header.i=@gmail.com header.s=20161025 header.b=jylQT2nv; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932479AbeFKIf5 (ORCPT + 99 others); Mon, 11 Jun 2018 04:35:57 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:34019 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932109AbeFKIfz (ORCPT ); Mon, 11 Jun 2018 04:35:55 -0400 Received: by mail-pl0-f66.google.com with SMTP id g20-v6so11923577plq.1; Mon, 11 Jun 2018 01:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=FTG8gJcA3AxjC8olL8p2LVHe6D4TEDxeNdhHMYDuNuc=; b=jylQT2nv1tua9+02t8mzyqwLBgg7N5Vb2JH0rVHpL3l+7sdKiJcieKVmyf33/IF5Un 9NQ1rCooxP90h7cHtEfju+ZubEH9NCa1zdT/5PGGeyZ0CDO/jLiitiDN9LSgml1m9BHm nfx88g4UKcIpCiggCuLuc3F0NVrzMU/kVIMVFw5crvU1NWhzQUtqQF6GL5MJYjZ/okVx JDDIKIX5MR9AdbhUT42be248MtOGY2L8+fy9UG5uNpnRQRkltKxWkwlV3hgr8st4NCNc rJwjIUPdoeyiSI4k374TmiBR8Un1iYhcMmadtuyeibKm7rHz61M2Xf84e2M84H/aKgu7 CULg== 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=FTG8gJcA3AxjC8olL8p2LVHe6D4TEDxeNdhHMYDuNuc=; b=pO2Tt2nAlkg+n2gPjk0XCAXHtWj5oiLui3sQADu2ZkoFwvPYC7gTloimplmDGoy6c6 TcQiO8B+/JvGQrYNpKoQ9nI1U0a99oWKBOddjhuAXITUOL6MbAW4Aeq97EJPAQvFJFLV kvVZPrsQEM0pDm0hJ3ltNQkLFbUzgyYc8E/OZ6jSwVa1HiBuh6LiuNWHQ6OLubpnIbvz HidMNHolM6NJnUCfO0rZYCBpO0zkmM2FeWbXD6ZqQQpMN0tnZW/oGLylJ8MRwOWGIb1h q7PYYAdh/uVeIuYQELW8Z+NdZgMv5u8uon0loDAV2POsiF5itOb6DMH2SkbqDAtVrNFg 3+WA== X-Gm-Message-State: APt69E1VU34tpa6XMtD92AaCIhh+WlhW9gjMuN4+SWmCJ5uYFP9j5VZ2 fKe11ze8f3uquLwBFbbyhDA= X-Received: by 2002:a17:902:ba87:: with SMTP id k7-v6mr17486767pls.271.1528706155215; Mon, 11 Jun 2018 01:35:55 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id y15-v6sm1939496pfm.136.2018.06.11.01.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 01:35:54 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Achim Leubner , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: gdth: add error handling for register_chrdev Date: Mon, 11 Jun 2018 16:35:48 +0800 Message-Id: <1528706148-35044-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When register_chrdev fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling register_chrdev. Signed-off-by: Zhouyang Jia --- drivers/scsi/gdth.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 8560479..d5a2af8 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -5198,6 +5198,11 @@ static int __init gdth_init(void) TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count)); major = register_chrdev(0,"gdth", &gdth_fops); + if (major < 0) { + printk("GDT-HA: Unable to register char device gdth.\n"); + return major; + } + register_reboot_notifier(&gdth_notifier); gdth_polling = FALSE; return 0; -- 2.7.4