Skip to content

Commit efc765e

Browse files
yarregshellixyz
authored andcommitted
Fixed dev pointer initialization (#4716)
1 parent e4391d5 commit efc765e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/drivers/bus.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ busDevice_t * busDeviceInit(busType_e bus, devHardwareType_e hw, uint8_t tag, re
118118
if (hw == descriptor->devHwType && (bus == descriptor->busType || bus == BUSTYPE_ANY) && (tag == descriptor->tag)) {
119119
// We have a candidate - initialize device context memory
120120
busDevice_t * dev = descriptor->devicePtr;
121-
memset(dev, 0, sizeof(busDevice_t));
121+
if (dev) {
122+
memset(dev, 0, sizeof(busDevice_t));
122123

123-
dev->descriptorPtr = descriptor;
124-
dev->busType = descriptor->busType;
125-
dev->flags = descriptor->flags;
124+
dev->descriptorPtr = descriptor;
125+
dev->busType = descriptor->busType;
126+
dev->flags = descriptor->flags;
126127

127-
if (dev) {
128128
switch (descriptor->busType) {
129129
default:
130130
case BUSTYPE_NONE:

0 commit comments

Comments
 (0)