| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Probing flash chips with QINFO records. |
|---|
| 3 | 4 | * (C) 2008 Korolev Alexey <akorolev@infradead.org> |
|---|
| 4 | 5 | * (C) 2008 Vasiliy Leonenko <vasiliy.leonenko@gmail.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or |
|---|
| 7 | | - * modify it under the terms of the GNU General Public License |
|---|
| 8 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 9 | | - * of the License, or (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|---|
| 19 | | - * 02110-1301, USA. |
|---|
| 20 | 6 | */ |
|---|
| 21 | 7 | #include <linux/module.h> |
|---|
| 22 | 8 | #include <linux/types.h> |
|---|
| .. | .. |
|---|
| 181 | 167 | lpddr.numchips = 1; |
|---|
| 182 | 168 | |
|---|
| 183 | 169 | numvirtchips = lpddr.numchips * lpddr.qinfo->HWPartsNum; |
|---|
| 184 | | - retlpddr = kzalloc(sizeof(struct lpddr_private) + |
|---|
| 185 | | - numvirtchips * sizeof(struct flchip), GFP_KERNEL); |
|---|
| 170 | + retlpddr = kzalloc(struct_size(retlpddr, chips, numvirtchips), |
|---|
| 171 | + GFP_KERNEL); |
|---|
| 186 | 172 | if (!retlpddr) |
|---|
| 187 | 173 | return NULL; |
|---|
| 188 | 174 | |
|---|