#2144 closed defect (fixed)

is a nill pointer dereferenced in console_open if pDeviceFlow is nill?

Reported by: Jeffrey Hill Owned by: Joel Sherrill
Priority: normal Milestone: 4.11
Component: bsps Version: 4.10
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description (last modified by Sebastian Huber)

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

Change History (2)

comment:1 Changed on Sep 11, 2013 at 9:18:47 PM by Jeffrey Hill

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:2 Changed on Dec 18, 2014 at 12:31:13 PM by Sebastian Huber

Description: modified (diff)
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.