* [PATCH] isdn/i4l: add error handling for try_module_get
@ 2018-06-12 4:43 Zhouyang Jia
2018-06-12 10:11 ` Sergei Shtylyov
0 siblings, 1 reply; 2+ messages in thread
From: Zhouyang Jia @ 2018-06-12 4:43 UTC (permalink / raw)
Cc: Zhouyang Jia, Karsten Keil, Kees Cook, Annie Cherkaev, Al Viro,
Jiten Thakkar, netdev, linux-kernel
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");
drv->locks++;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] isdn/i4l: add error handling for try_module_get
2018-06-12 4:43 [PATCH] isdn/i4l: add error handling for try_module_get Zhouyang Jia
@ 2018-06-12 10:11 ` Sergei Shtylyov
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2018-06-12 10:11 UTC (permalink / raw)
To: Zhouyang Jia
Cc: Karsten Keil, Kees Cook, Annie Cherkaev, Al Viro, Jiten Thakkar,
netdev, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-12 10:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 4:43 [PATCH] isdn/i4l: add error handling for try_module_get Zhouyang Jia
2018-06-12 10:11 ` Sergei Shtylyov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.