All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] crypto: qat - silence a static checker warning
@ 2015-08-21  8:47 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2015-08-21  8:47 UTC (permalink / raw)
  To: Tadeusz Struk
  Cc: Herbert Xu, David S. Miller, Allan, Bruce W, Ahsan Atta,
	qat-linux, linux-crypto, kernel-janitors

My static checker assumes that if we are getting numbers as a string
using kstrotoint() then that means they come from outside the kernel and
are untrustworthy.

This may or may not be true in this case, but it seems harmless to add
a range check here.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/crypto/qat/qat_common/adf_transport.c b/drivers/crypto/qat/qat_common/adf_transport.c
index d5d8198..ec3abf9 100644
--- a/drivers/crypto/qat/qat_common/adf_transport.c
+++ b/drivers/crypto/qat/qat_common/adf_transport.c
@@ -264,6 +264,10 @@ int adf_create_ring(struct adf_accel_dev *accel_dev, const char *section,
 		dev_err(&GET_DEV(accel_dev), "Can't get ring number\n");
 		return -EFAULT;
 	}
+	if (ring_num >= ARRAY_SIZE(bank->rings)) {
+		dev_err(&GET_DEV(accel_dev), "Invalid ring number\n");
+		return -EFAULT;
+	}
 
 	bank = &transport_data->banks[bank_num];
 	if (adf_reserve_ring(bank, ring_num)) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-24 14:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-21  8:47 [patch] crypto: qat - silence a static checker warning Dan Carpenter
2015-08-21  8:47 ` Dan Carpenter
2015-08-22 15:29 ` Tadeusz Struk
2015-08-22 15:29   ` Tadeusz Struk
2015-08-24 14:24   ` Herbert Xu
2015-08-24 14:24     ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.