| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * This file is part of wl1271 |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2008-2010 Nokia Corporation |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or |
|---|
| 9 | | - * modify it under the terms of the GNU General Public License |
|---|
| 10 | | - * version 2 as published by the Free Software Foundation. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 13 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | | - * General Public License for more details. |
|---|
| 16 | | - * |
|---|
| 17 | | - * You should have received a copy of the GNU General Public License |
|---|
| 18 | | - * along with this program; if not, write to the Free Software |
|---|
| 19 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
|---|
| 20 | | - * 02110-1301 USA |
|---|
| 21 | | - * |
|---|
| 22 | 8 | */ |
|---|
| 23 | 9 | |
|---|
| 24 | 10 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 86 | 72 | unsigned int *min_ver = (wl->fw_type == WL12XX_FW_TYPE_MULTI) ? |
|---|
| 87 | 73 | wl->min_mr_fw_ver : wl->min_sr_fw_ver; |
|---|
| 88 | 74 | char min_fw_str[32] = ""; |
|---|
| 75 | + int off = 0; |
|---|
| 89 | 76 | int i; |
|---|
| 90 | 77 | |
|---|
| 91 | 78 | /* the chip must be exactly equal */ |
|---|
| .. | .. |
|---|
| 119 | 106 | return 0; |
|---|
| 120 | 107 | |
|---|
| 121 | 108 | fail: |
|---|
| 122 | | - for (i = 0; i < NUM_FW_VER; i++) |
|---|
| 109 | + for (i = 0; i < NUM_FW_VER && off < sizeof(min_fw_str); i++) |
|---|
| 123 | 110 | if (min_ver[i] == WLCORE_FW_VER_IGNORE) |
|---|
| 124 | | - snprintf(min_fw_str, sizeof(min_fw_str), |
|---|
| 125 | | - "%s*.", min_fw_str); |
|---|
| 111 | + off += snprintf(min_fw_str + off, |
|---|
| 112 | + sizeof(min_fw_str) - off, |
|---|
| 113 | + "*."); |
|---|
| 126 | 114 | else |
|---|
| 127 | | - snprintf(min_fw_str, sizeof(min_fw_str), |
|---|
| 128 | | - "%s%u.", min_fw_str, min_ver[i]); |
|---|
| 115 | + off += snprintf(min_fw_str + off, |
|---|
| 116 | + sizeof(min_fw_str) - off, |
|---|
| 117 | + "%u.", min_ver[i]); |
|---|
| 129 | 118 | |
|---|
| 130 | 119 | wl1271_error("Your WiFi FW version (%u.%u.%u.%u.%u) is invalid.\n" |
|---|
| 131 | 120 | "Please use at least FW %s\n" |
|---|