Skip to contentSkip to conversation

driver-core: Fix null reference in subsys_interface_unregister

PATCH 최종환 2 participants 2 messages Jan 17, 2012 Driver core

lore
Share & tools
lore

최종환

author
#0 lore raw
Quoted 10 lines · Greg KH
Quoted 3 lines · On Sat, Jan 14, 2012 at 11:06:03AM +0900, [email protected] 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

drivers/base/bus.c +4 -2
index 99dc592..4ddb38b 100644
@@ -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) {
Signature · 7 lines
sif is already used, but  null pointer check for sif later.
so i think that sif should be checked before use it.


Sorry about that, since my e-mail client has a problem,
 I couldn't send that to mailing list. I will send it to mailing list.
 Thanks.�淸�{.n�+돴윯돪�+%듚�깁負쪐w��{.n�+돴쪐{깸G쳺��{ay����,j�f"톒쉹��묎�z_溫(�쉸듶줷"얎�m����G쳺�◀?솳鈺�&x�~뤳턨O뺞촾퇉v�^�m����띠�◀?뻀�
#1 lore raw
Quoted 40 lines · 최종환
Quoted 10 lines · Greg KH
Quoted 3 lines · On Sat, Jan 14, 2012 at 11:06:03AM +0900, [email protected] 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

drivers/base/bus.c +4 -2
index 99dc592..4ddb38b 100644
@@ -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) {
Signature · 2 lines
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