lkml.org 
[lkml]   [2012]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: Re: [PATCH] driver-core: Fix null reference in subsys_interface_unregister
On Tue, Jan 17, 2012 at 12:35:35AM +0000, 최종환 wrote:
> Greg KH wrote:
>
> >On Sat, Jan 14, 2012 at 11:06:03AM +0900, jhbird.choi@samsung.com wrote:
> >> From: Jonghwan Choi
> > >
> > >Check if the sif is not NULL before de-referencing it
>
> >Why would it be? Have you hit this somehow? If so, in what code?
>
> > thanks,
>
> > greg k-h
>
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 99dc592..4ddb38b 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -1193,13 +1193,15 @@ EXPORT_SYMBOL_GPL(subsys_interface_register);
>
> void subsys_interface_unregister(struct subsys_interface *sif)
> {
> - struct bus_type *subsys = sif->subsys; // -> Sif is already used, that means sif is not null
> + struct bus_type *subsys;
> struct subsys_dev_iter iter;
> struct device *dev;
>
> - if (!sif) // -> Check whether sif is null
> + if (!sif || !sif->subsys)
> return;
>
> + subsys = sif->subsys;
> +
> mutex_lock(&subsys->p->mutex);
> list_del_init(&sif->node);
> if (sif->remove_dev) {
> --
>
> sif is already used, but null pointer check for sif later.
> so i think that sif should be checked before use it.

Yes, you are right, I missed the previous usage. I'll queue this up for
3.4.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-01-17 02:03    [W:0.054 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site