summaryrefslogtreecommitdiffstats
path: root/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
diff options
context:
space:
mode:
authorIoana Radulescu2017-09-28 16:10:33 +0200
committerGreg Kroah-Hartman2017-10-03 18:34:56 +0200
commit8dabf52ffb6445fa5bcc8b6d2ecb615f60d0dd12 (patch)
tree41177623a4daa6077ab20bfdbc1c9725002a4228 /drivers/staging/fsl-mc/bus/dpio/dpio-service.c
parentstaging: ccree: else is not generally useful after a break or return (diff)
downloadkernel-qcow2-linux-8dabf52ffb6445fa5bcc8b6d2ecb615f60d0dd12.tar.gz
kernel-qcow2-linux-8dabf52ffb6445fa5bcc8b6d2ecb615f60d0dd12.tar.xz
kernel-qcow2-linux-8dabf52ffb6445fa5bcc8b6d2ecb615f60d0dd12.zip
staging: fsl-mc/dpio: Fix incorrect comparison
For some dpio functions, a cpu id parameter value of -1 is valid and means "any". But when trying to validate this param value against an upper limit, in this case num_possible_cpus(), we risk obtaining the wrong result due to an implicit cast. Avoid an incorrect check result by explicitly comparing the cpu id with the "any" value before verifying the upper bound. Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/fsl-mc/bus/dpio/dpio-service.c')
-rw-r--r--drivers/staging/fsl-mc/bus/dpio/dpio-service.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index f8096828f5b7..a609ec82daf3 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -76,7 +76,7 @@ static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
if (d)
return d;
- if (unlikely(cpu >= num_possible_cpus()))
+ if (cpu != DPAA2_IO_ANY_CPU && cpu >= num_possible_cpus())
return NULL;
/*
@@ -121,7 +121,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc)
return NULL;
/* check if CPU is out of range (-1 means any cpu) */
- if (desc->cpu >= num_possible_cpus()) {
+ if (desc->cpu != DPAA2_IO_ANY_CPU && desc->cpu >= num_possible_cpus()) {
kfree(obj);
return NULL;
}