2011-05-13 05:53:50

by Julia Lawall

[permalink] [raw]
Subject: question about drivers/isdn/hisax/st5481_init.c

The function probe_st5481 allocates an adapter value using kzalloc, adds
it to adapter_list, and then performs various initialization operations,
which may fail. adapter_list is a static variable that is never otherwise
referenced in the file. There is a list_del that removes the adapter from
the list in the function disconnect_st5481. The presence of the adapter
on the list makes it possibly unsafe to free adapter in the failure cases.

Could the list just be removed, if it is not being used anywhere?

Or if the list should be kept because it is useful or it is planned to be
useful in the future, could the insertion into the list be moved to the
end of the function, after the potentially failing operations, so that
adapter can be freed when a failure occurs?

julia


2011-05-13 13:20:32

by Ben Hutchings

[permalink] [raw]
Subject: Re: question about drivers/isdn/hisax/st5481_init.c

On Fri, 2011-05-13 at 07:53 +0200, Julia Lawall wrote:
> The function probe_st5481 allocates an adapter value using kzalloc, adds
> it to adapter_list, and then performs various initialization operations,
> which may fail. adapter_list is a static variable that is never otherwise
> referenced in the file. There is a list_del that removes the adapter from
> the list in the function disconnect_st5481. The presence of the adapter
> on the list makes it possibly unsafe to free adapter in the failure cases.
>
> Could the list just be removed, if it is not being used anywhere?
>
> Or if the list should be kept because it is useful or it is planned to be
> useful in the future, could the insertion into the list be moved to the
> end of the function, after the potentially failing operations, so that
> adapter can be freed when a failure occurs?

Some older drivers have these device lists hanging around from before
the device model has implemented. If the list isn't being used now then
it's probably fine to remove.

Ben.

--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

2011-05-13 13:35:26

by Julia Lawall

[permalink] [raw]
Subject: Re: question about drivers/isdn/hisax/st5481_init.c

On Fri, 13 May 2011, Ben Hutchings wrote:

> On Fri, 2011-05-13 at 07:53 +0200, Julia Lawall wrote:
> > The function probe_st5481 allocates an adapter value using kzalloc, adds
> > it to adapter_list, and then performs various initialization operations,
> > which may fail. adapter_list is a static variable that is never otherwise
> > referenced in the file. There is a list_del that removes the adapter from
> > the list in the function disconnect_st5481. The presence of the adapter
> > on the list makes it possibly unsafe to free adapter in the failure cases.
> >
> > Could the list just be removed, if it is not being used anywhere?
> >
> > Or if the list should be kept because it is useful or it is planned to be
> > useful in the future, could the insertion into the list be moved to the
> > end of the function, after the potentially failing operations, so that
> > adapter can be freed when a failure occurs?
>
> Some older drivers have these device lists hanging around from before
> the device model has implemented. If the list isn't being used now then
> it's probably fine to remove.

OK, I'll propose a patch in that direction. Thanks.

julia