Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4882038imm; Mon, 11 Jun 2018 21:53:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK0iclWM5YpD8/w0Nj0h0UdwNVRY7mdbwbqzy20HnMFaf6Dck7nTO1MPl2BCvUznBzOEXFO X-Received: by 2002:a63:aa03:: with SMTP id e3-v6mr1804255pgf.169.1528779183464; Mon, 11 Jun 2018 21:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528779183; cv=none; d=google.com; s=arc-20160816; b=G517mQeajEr2ceqjlGJPAfoBb1HM0yjTCEn3SnYTSvWoD8soFqJMVZpzB3QCxCuQYx eW+JlPF96W7icOnT5Q/68jn3nOuITE4+Y7O6VK6IxEBVMwERtp1IZeb+zxaese1QYV/Q +JRib0EYTG3V9GM74L3wdXHB3lTNNgkHm4dfiGPSqFqwr2oimiPPfozFtwSEMB9QLub6 2CtghrCbPJZ9brKslZk3QLSNgq1ojPvAyWmC4DNqITpGTGJ0ILS3p/3Kz6qldPyMqq7v bq/bSGqh6PkB6p1DPMdfRPImWyMQzvqiozCudWphK59jHxeZ78WYK79CjZuNHDZlVI52 hXyQ== 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=1TKrvCSm+Eh984/81unuiMPXREU2a4wzPgn4YkBsUNU=; b=vTvwNpCrgPo7JWRKQqTQSd2TnwmQDzTQHZgRTAI1O3K/KqcWTQZHJuwHpN6/0NbAOp deb/ZNIZ3dIFTnzloKBH7Q2YTzAlV7Er6/uPWVhuekU9N+cUJPHo1t+1hp1FZkHaJ/bp dvXVS+ngeSum9D4FQGKfIjUjTW94uxlcnXVbvQVvoThoKURMZ+KblS0SDMTR6LVUaVXR Aygz/+Akc5cZ9sFw92gw9RXM4rApeN2DguPEqs0PWmaGoMpK1xL6U1Uu3Zb+lKgRULgt lsf8lmq94di/Wk7W5Ul24u0OV4l+KbgmNaAXpubmrTLREPx9pX2DBk6clg+kqv6o46XQ RxDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HXQuK5YG; 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 3-v6si31225573pla.418.2018.06.11.21.52.49; Mon, 11 Jun 2018 21:53:03 -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=HXQuK5YG; 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 S932328AbeFLEuy (ORCPT + 99 others); Tue, 12 Jun 2018 00:50:54 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43685 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752046AbeFLEuw (ORCPT ); Tue, 12 Jun 2018 00:50:52 -0400 Received: by mail-pf0-f194.google.com with SMTP id y8-v6so2357650pfm.10; Mon, 11 Jun 2018 21:50:52 -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=1TKrvCSm+Eh984/81unuiMPXREU2a4wzPgn4YkBsUNU=; b=HXQuK5YGv7k+Fu1oI9NJDEb5+4OIld8snzh/dgL6aVPVOUT3Qydhe6Du9dOOBi1CPy PWTIvs1cgOYBwKkgywK01j/iC0Gj9PROwTSFzCZy6gexwGVKyVINEve3l7veJsv1bHKV qdvuHFWvo8ueeY1pRFoTLIO46rRkmRir7/L/HmMsTliZ2QotvyFCd7SANFKbKRvVmI25 IBCtY90aVQJS/rqK+9GZ2qZUaImP2S7trW0rFdMVgkLwACTKu6/+j8du6cwZz2zEHEUt XsnEJGAXP1YQQtGBsmOWlu6bs+YOYJSb7uYs4iZfAs+HXEdmFKIE9OXu3z6EqSM95k5d zhwQ== 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=1TKrvCSm+Eh984/81unuiMPXREU2a4wzPgn4YkBsUNU=; b=V4Ewhl1FBKThhNPsQSPxQ1J8mMnw9LPQKKaXALBXBdkzTF7VTEKtw+xcNXQtDZ5NYj UKDzw/nzW2EbvumkVqZJLTe7/+fU8/l6SJfUxhHaDd2qcgBYdkvs9Lzo/qHD4Hz61y+P GueulBX7KzhZYkB9IeHUJq+iw5KQFUoNXxfqjWoFuX5kf7bOGY1pss4uWnmiW3fylcg/ 9vh+qbohMLpHfIXW0oGkSiDSe6tUurkY6fo15DZ8B1wc3b0DWvVys6VQjlezQ82FNpgd xPk6czoCF+XHuTiAWtGc/7rR6zeoTTGBJN3z2nYyboecTix2RjILXe1DuFpGU3WAznbg DUEw== X-Gm-Message-State: APt69E17ga8PuQVVdRquSatSAfsbFH23DRZhnLYlMjfdzdJd8va+kXBf jmGsgvj2DbusXKOQputEUxyzUBYTJRU= X-Received: by 2002:a62:c809:: with SMTP id z9-v6mr2127331pff.5.1528779052004; Mon, 11 Jun 2018 21:50:52 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id z26-v6sm3652975pfd.60.2018.06.11.21.50.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:50:51 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Jason Wessel , Daniel Thompson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] tty: serial: add error handling for try_module_get Date: Tue, 12 Jun 2018 12:50:46 +0800 Message-Id: <1528779046-42341-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 try_module_get fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling try_module_get. Signed-off-by: Zhouyang Jia --- drivers/tty/serial/kgdboc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index b4ba2b1..641e22a 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -286,8 +286,10 @@ static void kgdboc_pre_exp_handler(void) con_debug_enter(vc_cons[fg_console].d); } /* Increment the module count when the debugger is active */ - if (!kgdb_connected) - try_module_get(THIS_MODULE); + if (!kgdb_connected) { + if (!try_module_get(THIS_MODULE)) + printk(KERN_ERR "kgdboc: cannot get module.\n"); + } } static void kgdboc_post_exp_handler(void) -- 2.7.4