[RTEMS Project] #2144: is a nill pointer dereferenced in console_open if pDeviceFlow is nill?
RTEMS trac
trac at rtems.org
Thu Dec 18 12:31:13 UTC 2014
#2144: is a nill pointer dereferenced in console_open if pDeviceFlow is nill?
--------------------+----------------------------
Reporter: johill | Owner: joel.sherrill
Type: defect | Status: closed
Priority: normal | Milestone: 4.11
Component: bsps | Version: 4.10
Severity: normal | Resolution: fixed
Keywords: |
--------------------+----------------------------
Changes (by sebastian.huber):
* status: new => closed
* resolution: => fixed
Old description:
> It seems that many BSPs initialize pDeviceFlow to nill so perhaps the
> following is a good idea in console_open. Maybe pDeviceFlow is
> initialized in generic code, but this isnt obvious after a quick search.
>
> Thanks,
>
> Jeff Hill
>
> libbsp/shared/console.c
>
> @@ -70,8 +70,14 @@ rtems_device_driver console_open(
> Callbacks.pollRead = cptr->pDeviceFns->deviceRead;
> Callbacks.write = cptr->pDeviceFns->deviceWrite;
> Callbacks.setAttributes =
> cptr->pDeviceFns->deviceSetAttributes;
> - Callbacks.stopRemoteTx =
> cptr->pDeviceFlow->deviceStopRemoteTx;
> - Callbacks.startRemoteTx =
> cptr->pDeviceFlow->deviceStartRemoteTx;
> + if ( cptr->pDeviceFlow ) {
> + Callbacks.stopRemoteTx =
> cptr->pDeviceFlow->deviceStopRemoteTx;
> + Callbacks.startRemoteTx =
> cptr->pDeviceFlow->deviceStartRemoteTx;
> + }
> + else {
> + Callbacks.stopRemoteTx = 0;
> + Callbacks.startRemoteTx = 0;
> + }
> Callbacks.outputUsesInterrupts =
> cptr->pDeviceFns->deviceOutputUsesInterrupts;
>
> /* XXX what about
New description:
It seems that many BSPs initialize pDeviceFlow to nill so perhaps the
following is a good idea in console_open. Maybe pDeviceFlow is initialized
in generic code, but this isnt obvious after a quick search.
Thanks,
Jeff Hill
libbsp/shared/console.c
@@ -70,8 +70,14 @@ rtems_device_driver console_open(
Callbacks.pollRead = cptr->pDeviceFns->deviceRead;
Callbacks.write = cptr->pDeviceFns->deviceWrite;
Callbacks.setAttributes = cptr->pDeviceFns->deviceSetAttributes;
- Callbacks.stopRemoteTx = cptr->pDeviceFlow->deviceStopRemoteTx;
- Callbacks.startRemoteTx =
cptr->pDeviceFlow->deviceStartRemoteTx;
+ if ( cptr->pDeviceFlow ) {
+ Callbacks.stopRemoteTx =
cptr->pDeviceFlow->deviceStopRemoteTx;
+ Callbacks.startRemoteTx =
cptr->pDeviceFlow->deviceStartRemoteTx;
+ }
+ else {
+ Callbacks.stopRemoteTx = 0;
+ Callbacks.startRemoteTx = 0;
+ }
Callbacks.outputUsesInterrupts =
cptr->pDeviceFns->deviceOutputUsesInterrupts;
/* XXX what about
--
Comment:
[cdc056098d77a003e870174951b69f044344c075/rtems]
--
Ticket URL: <http://devel.rtems.org/ticket/2144#comment:2>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list