Re: Re: [PATCH] driver-core: Fix null reference insubsys_interface_unregister

From: 최종환
Date: Mon Jan 16 2012 - 19:35:38 EST


Greg KH wrote:

>On Sat, Jan 14, 2012 at 11:06:03AM +0900, jhbird.choi@xxxxxxxxxxx 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.


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.?移»®&Þ~º&¶¬–+-깁負¥Šw®왢쎉喝méb욎dz받–)í끾èw*jgП¨¶‰šŽ듶¢j/곴äz받–듺2듷솳鈺Ú&¢)傘«a뛴®G«앶h®æj:+v돣Šwè녪¥>W슧違iÛaxPjØm¶Ÿÿà -»+껠dš_