Re: [PATCH] gpiolib: Fix crash when exporting non-existant gpio

From: Daniel Santos
Date: Sat Aug 24 2013 - 16:37:39 EST



On 08/24/2013 02:57 PM, Guenter Roeck wrote:

Looking into calling code, desc_to_gpio() is clearly not supposed to return an error,
and it will result in odd behavior if it returns -1. For example, the resulting debug
message of "gpio--1 (...) status ..." is not very useful.

It would make more sense to fix the calling code. You could for example
validate in affected functions if the gpio pin exists by not only
checking for desc but also for desc->chip. Another option might be
to have gpio_to_desc() return NULL if desc->chip is NULL.

Yes, you are correct of course. I guess I was just being lazy. :) I'll re-submit.

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