* potential NULL dereference at get_target_state in drivers/thermal/fair_share.c
@ 2013-03-30 10:05 devendra.aaru
2013-04-01 1:09 ` Zhang Rui
0 siblings, 1 reply; 2+ messages in thread
From: devendra.aaru @ 2013-03-30 10:05 UTC (permalink / raw)
To: Zhang Rui, linux-pm, Durgadoss R
Hello Zhang, Durgadoss,
I have found a code that does this cdev->ops->get_max_state
static long get_target_state(struct thermal_zone_device *tz,
struct thermal_cooling_device *cdev, int weight, int level)
{
unsigned long max_state;
cdev->ops->get_max_state(cdev, &max_state);
return (long)(weight * level * max_state) / (100 * tz->trips);
}
as the ops can be NULL the panic can occur. if not i have to check for
a valid get_max_state pointer. so if the ops->get_max_state is NULL
what should i suppose to be returning here?
thanks a lot,
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: potential NULL dereference at get_target_state in drivers/thermal/fair_share.c
2013-03-30 10:05 potential NULL dereference at get_target_state in drivers/thermal/fair_share.c devendra.aaru
@ 2013-04-01 1:09 ` Zhang Rui
0 siblings, 0 replies; 2+ messages in thread
From: Zhang Rui @ 2013-04-01 1:09 UTC (permalink / raw)
To: devendra.aaru; +Cc: linux-pm, Durgadoss R
On Sat, 2013-03-30 at 15:35 +0530, devendra.aaru wrote:
> Hello Zhang, Durgadoss,
>
> I have found a code that does this cdev->ops->get_max_state
>
> static long get_target_state(struct thermal_zone_device *tz,
> struct thermal_cooling_device *cdev, int weight, int level)
> {
> unsigned long max_state;
>
> cdev->ops->get_max_state(cdev, &max_state);
>
> return (long)(weight * level * max_state) / (100 * tz->trips);
> }
>
> as the ops can be NULL the panic can occur. if not i have to check for
> a valid get_max_state pointer. so if the ops->get_max_state is NULL
> what should i suppose to be returning here?
>
any cdev must be registered with valid ops and ops->get_max_state.
if ops or ops->get_max_state is NULL, it suggests a big problem, like
racing issue, etc, and IMO, a panic is more meaningful for us to debug
the problem here.
thanks,
rui
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-01 1:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-30 10:05 potential NULL dereference at get_target_state in drivers/thermal/fair_share.c devendra.aaru
2013-04-01 1:09 ` Zhang Rui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).