diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index 0ed190b444782fb8032a95fd933cb8f7aa0d889b..99cd2d11a95ac6ce40c534045d2d855373a586ee 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -1351,7 +1351,7 @@ static void refresh_all_favorite(struct unistimsession *pte)
 
 static int is_key_favorite(struct unistim_device *d, int fav)
 {
-	if ((fav < 0) && (fav > 5)) {
+	if ((fav < 0) || (fav >= FAVNUM)) {
 		return 0;
 	}
 	if (d->sline[fav]) {
@@ -1365,7 +1365,7 @@ static int is_key_favorite(struct unistim_device *d, int fav)
 
 static int is_key_line(struct unistim_device *d, int fav)
 {
-	if ((fav < 0) && (fav > 5)) {
+	if ((fav < 0) || (fav >= FAVNUM)) {
 		return 0;
 	}
 	if (!d->sline[fav]) {