mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
mxser: alloc only needed # of ports
Many boards have only 2 ports. But we always allocate 8 ports (struct mxser_port) in each struct mxser_board. Switch this to an empty/variable sized array ([]) and allocate the needed number of ports using struct_size helper in ->probe. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-54-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f8b6b327aa
commit
ad1c92ff6e
1 changed files with 3 additions and 2 deletions
|
@ -275,7 +275,7 @@ struct mxser_board {
|
||||||
enum mxser_must_hwid must_hwid;
|
enum mxser_must_hwid must_hwid;
|
||||||
speed_t max_baud;
|
speed_t max_baud;
|
||||||
|
|
||||||
struct mxser_port ports[MXSER_PORTS_PER_BOARD];
|
struct mxser_port ports[];
|
||||||
};
|
};
|
||||||
|
|
||||||
static DECLARE_BITMAP(mxser_boards, MXSER_BOARDS);
|
static DECLARE_BITMAP(mxser_boards, MXSER_BOARDS);
|
||||||
|
@ -1923,7 +1923,8 @@ static int mxser_probe(struct pci_dev *pdev,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
brd = devm_kzalloc(&pdev->dev, sizeof(*brd), GFP_KERNEL);
|
brd = devm_kzalloc(&pdev->dev, struct_size(brd, ports, nports),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!brd)
|
if (!brd)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue