Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5135892imm; Tue, 12 Jun 2018 03:12:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLB2dJdhrFQdh8Jga3/YrTMr9NPiodcAkYHyf54+4jUjZthQyUAqVHfG8gX5EHotDd8Cg+A X-Received: by 2002:a65:4487:: with SMTP id l7-v6mr2645208pgq.357.1528798326401; Tue, 12 Jun 2018 03:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528798326; cv=none; d=google.com; s=arc-20160816; b=i8L2WUgaZbtIpBtrRJk3iJFT2nql4CCQhE5fSXtxoSH1ZANmeOXJT4sP/9u8ljE8DX +RDlKkarxaHh36okob9voO0XYUytRpE5rkY3snipQkjzbP/nIHwcQikran0ePHLLj2X/ TUdGj8/hFcNfww0ughIgj1zVo5DgsP47Emi40JbRi5G2z88AoyaSbHEWG1lDTMXKXoRP IjlCh3akrXx71RGIuVxcP+6XeJ7MYV/PUQMDeW4dRu07c08kWaubVgWLD9QY37NTliwI j6CdLwwv9O4cd0/sT0/44yIUbRT59FLvdHCwZhkQtWQ4/r/W8kkPS3wOp8/0sPKHzn7O SsGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=UI+XqWZ4n8sigZuaALnjT5i0YxPNoao9KFDIICJlphQ=; b=F76YiQH8hb1ib04aHznQtz7O+/lFBIZUayIIfsnFq2YDvYW79qsWoNJ0q5gMqJAsrU Ypq1YQhIsbpDp7JFLejCGU49RnqFggyPWFeVtSx06/BQBAKOiuG2GdN4P+kxJskZAGXy 4UU4OtOKMgYeI58pabld8usGMvoBrCc9sgi2LBnFcyrwkZk/NaQviXqiwFQPdZbGONgZ RRaJImidmZ0UJhl2bCgqAx4tJHby3CQx/29weijr9d5185DB3FoIV0XeUNaPJnSd5zof uq2FfSkjeKMnfNJsR8b1ngQJ3U0R6DiL+nwyMOxUBMLYXB3opfpB9LHVfhHuFtepsiW9 A92A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=pP46h51S; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1-v6si466906pgo.68.2018.06.12.03.11.50; Tue, 12 Jun 2018 03:12:06 -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=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=pP46h51S; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754123AbeFLKLQ (ORCPT + 99 others); Tue, 12 Jun 2018 06:11:16 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34476 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753206AbeFLKLO (ORCPT ); Tue, 12 Jun 2018 06:11:14 -0400 Received: by mail-lf0-f65.google.com with SMTP id o9-v6so35117985lfk.1 for ; Tue, 12 Jun 2018 03:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=UI+XqWZ4n8sigZuaALnjT5i0YxPNoao9KFDIICJlphQ=; b=pP46h51SzH0+5n69C36EFd26Ohp8iEi92pnPIFN9yUnfB4FU57riBeL6e9yR8pMsUZ 59GFm+sTqKvuFvHDMtI7J0oB8pqjst5i1TlD0l4WmP4IpiIIWhpsm4TP01vv5dtANXgO 2W6oZqzV6EfLA/lnll9JxATCi9KfHbdd9wL3k0gJ2Ihrf3ivROfBzqniBliYPN8BxXsU QEvw+KRk0bOGQ5YFrwnrL3b5Ij74sBe70P0/rcm2u4272m4x9tYz2RYWrsWFfsKDsSwu UK04uDixWVsQQFUIlO3FeZpik9xNuvjk836jnqek0lvb1lGupymjCbehDI/mPNw/3Qts rZVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UI+XqWZ4n8sigZuaALnjT5i0YxPNoao9KFDIICJlphQ=; b=n70dZgVa/U+V/wrPqfuD+ggFnFrq+wYOwrQAI/H1NqDmSq14zoJHUwUYhZC3ka+yw7 b0Qc9vMhej7+ypOJO0Eel6eN/Yv1ZUePE9EbSQbYUpelqdV/Jdq14OW9yxrvAx5eLRMZ NxiOI/hOl21oKK+TOyKQlIh0TEYj/YhSeeNY624OREk5pWkYRcFMrW2jo3ic+l7lhGtq bMH3RyTDs2A1lMCYbUTLds981pr6iY2iE95sICAXX/qO9W+nCfrGMtMtma87H1777Z1A wR3o18wB2hoFpf62Zo19T5jo6ZWkPjrTkhn2b+KOaNkc6UPDOjacBdAY1rvTI2t/FNTO 6lLQ== X-Gm-Message-State: APt69E0PVO3L+WWybb1L5h3VcUumnauIOTXeM/3qW3H4UpeANlaV+oOM esWqjN+F3xf2aA+Zqfb1pLMZbJvU6yQ= X-Received: by 2002:a2e:4811:: with SMTP id v17-v6mr1868261lja.39.1528798272678; Tue, 12 Jun 2018 03:11:12 -0700 (PDT) Received: from [192.168.0.126] ([31.173.81.249]) by smtp.gmail.com with ESMTPSA id 66-v6sm136321ljz.28.2018.06.12.03.11.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 03:11:11 -0700 (PDT) Subject: Re: [PATCH] isdn/i4l: add error handling for try_module_get To: Zhouyang Jia Cc: Karsten Keil , Kees Cook , Annie Cherkaev , Al Viro , Jiten Thakkar , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1528778635-41763-1-git-send-email-jiazhouyang09@gmail.com> From: Sergei Shtylyov Message-ID: <5a6a774c-156e-3e13-eda8-ed6c81722888@cogentembedded.com> Date: Tue, 12 Jun 2018 13:11:13 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1528778635-41763-1-git-send-email-jiazhouyang09@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/12/2018 7:43 AM, Zhouyang Jia wrote: > 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/isdn/i4l/isdn_common.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c > index 7c6f3f5..7e52851 100644 > --- a/drivers/isdn/i4l/isdn_common.c > +++ b/drivers/isdn/i4l/isdn_common.c > @@ -71,7 +71,8 @@ static int isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding); > static inline void > isdn_lock_driver(isdn_driver_t *drv) > { > - try_module_get(drv->interface->owner); > + if (!try_module_get(drv->interface->owner)) > + printk(KERN_WARNING "isdn_lock_driver: cannot get module\n"); Do you call this error handling code? :-) And BTW we have pr_warn() for that. > drv->locks++; > } > MBR, Sergei