mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: Karsten Keil <isdn@linux-pingi.de>,
	Kees Cook <keescook@chromium.org>,
	Annie Cherkaev <annie.cherk@gmail.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Jiten Thakkar <jitenmt@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] isdn/i4l: add error handling for try_module_get
Date: Tue, 12 Jun 2018 13:11:13 +0300	[thread overview]
Message-ID: <5a6a774c-156e-3e13-eda8-ed6c81722888@cogentembedded.com> (raw)
In-Reply-To: <1528778635-41763-1-git-send-email-jiazhouyang09@gmail.com>

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 <jiazhouyang09@gmail.com>
> ---
>   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

      reply	other threads:[~2018-06-12 10:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12  4:43 Zhouyang Jia
2018-06-12 10:11 ` Sergei Shtylyov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5a6a774c-156e-3e13-eda8-ed6c81722888@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=annie.cherk@gmail.com \
    --cc=isdn@linux-pingi.de \
    --cc=jiazhouyang09@gmail.com \
    --cc=jitenmt@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®