Skip to content

Commit

Permalink
staging: most: avoid null pointer dereference when iface is null
Browse files Browse the repository at this point in the history
In the case where the pointer iface is null then the reporting of this
error will dereference iface when printing an error message causing which
is not ideal.  Since the majority of callers to most_register_interface
report an error when -EINVAL is returned a simple fix is to just remove
the error message, I doubt it will be missed.

Addresses-Coverity: ("Dereference after null check")
Fixes: 57562a7 ("Staging: most: add MOST driver's core module")
Signed-off-by: Colin Ian King <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Colin Ian King authored and gregkh committed Jun 25, 2020
1 parent 75d0bf8 commit e4463e4
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/most/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,10 +1283,8 @@ int most_register_interface(struct most_interface *iface)
struct most_channel *c;

if (!iface || !iface->enqueue || !iface->configure ||
!iface->poison_channel || (iface->num_channels > MAX_CHANNELS)) {
dev_err(iface->dev, "Bad interface or channel overflow\n");
!iface->poison_channel || (iface->num_channels > MAX_CHANNELS))
return -EINVAL;
}

id = ida_simple_get(&mdev_id, 0, 0, GFP_KERNEL);
if (id < 0) {
Expand Down

0 comments on commit e4463e4

Please sign in to comment.