Re: [PATCH] [net/irda]: new Blackfin on-chip SIR IrDA driver

From: Mike Frysinger
Date: Thu Mar 12 2009 - 00:34:18 EST


On Thu, Mar 12, 2009 at 00:30, gyang wrote:
> On Thu, 2009-03-12 at 00:23 -0400, Mike Frysinger wrote:
>> On Thu, Mar 12, 2009 at 00:17, gyang wrote:
>> > On Wed, 2009-03-11 at 06:43 -0400, Mike Frysinger wrote:
>> >> On Wed, Mar 11, 2009 at 05:56, graff yang wrote:
>> >> > On Wed, Mar 11, 2009 at 3:57 PM, Mike Frysinger wrote:
>> >> >> On Wed, Mar 11, 2009 at 03:29, Â<graff.yang@xxxxxxxxx> wrote:
>> >> >>> +static int __devinit bfin_sir_probe(struct platform_device *pdev)
>> >> >>> +{
>> >> >>> + Â Â Â struct net_device *dev;
>> >> >>> + Â Â Â struct bfin_sir_self *self;
>> >> >>> + Â Â Â unsigned int baudrate_mask;
>> >> >>> + Â Â Â struct bfin_sir_port *sir_port;
>> >> >>> + Â Â Â int err;
>> >> >>> +
>> >> >>> + Â Â Â err = peripheral_request_list(per[pdev->id], DRIVER_NAME);
>> >> >>
>> >> >> what if pdev->id is set to 12512 ?
>> >> >
>> >> > The pdev->id is defined in board files, for example, uart0 should be 0.
>> >>
>> >> so ? Âwhat's to stop the user from setting it to 12415 ? Âthe driver
>> >> must sanity check these things. Âyou can never assume platform dev
>> >> resources always have valid pointers and valid values.
>> >
>> > How about to limit the pdev->id to be 0,1,2,3 ?
>> > I can extend the per to be
>> > static const unsigned short per[][4] = {
>> > Â Â Â Â{P_UART0_RX, P_UART0_TX, 0, 0},
>> > Â Â Â Â{P_UART1_RX, P_UART1_TX, 0, 1},
>> > Â Â Â Â{P_UART2_RX, P_UART2_TX, 0, 2},
>> > Â Â Â Â{P_UART3_RX, P_UART3_TX, 0, 3},
>> > };
>> >
>> > then check (pdev->id >= 0 && pdev->id < ARRAY_SIZE(per) &&
>> > per[pdev->id][3] == pdev->id)
>>
>> the last check is redundant. Âthe first two should be added.
>
> I'm afraid of some cases such as uart0 uses id 1, will cause driver not
> work, and not any warning message.

then the call to peripheral request would fail as expected
-mike
--
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/