[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210906065650.GD1957@kadam>
Date: Mon, 6 Sep 2021 09:56:50 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Pavel Skripkin <paskripkin@...il.com>
Cc: Larry.Finger@...inger.net, phil@...lpotter.co.uk,
gregkh@...uxfoundation.org, straube.linux@...il.com,
fmdefrancesco@...il.com, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: r8188eu: fix type mismacth
On Sun, Sep 05, 2021 at 11:52:16PM +0300, Pavel Skripkin wrote:
> smatch says:
> rtw_cmd.c:1165 rtw_setassocsta_cmd() warn: struct type mismatch 'set_stakey_rsp vs set_assocsta_rsp'
>
> Since psetassocsta_rsp has struct set_stakey_rsp * type, it looks like
> copy-paste failure. This error didn't cause any bugs, because
> sizeof(struct set_assocsta_parm) > sizeof(struct set_stakey_rsp), but
> there is no reason for allocation extra unused memory
>
> Fixes: 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver")
> Signed-off-by: Pavel Skripkin <paskripkin@...il.com>
> ---
> drivers/staging/r8188eu/core/rtw_cmd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
> index fee4208dacba..afe6c7fa594d 100644
> --- a/drivers/staging/r8188eu/core/rtw_cmd.c
> +++ b/drivers/staging/r8188eu/core/rtw_cmd.c
> @@ -1162,7 +1162,7 @@ u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr)
> goto exit;
> }
>
> - psetassocsta_rsp = kzalloc(sizeof(struct set_assocsta_rsp), GFP_ATOMIC);
> + psetassocsta_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_ATOMIC);
> if (!psetassocsta_rsp) {
> kfree(ph2c);
> kfree(psetassocsta_para);
I'm not sure this is correct. Might be, might be not. But we use
sizeof(struct set_assocsta_rsp) later in the function so it likely leads
to memory corruption.
ph2c->rsp = (u8 *)psetassocsta_rsp;
ph2c->rspsz = sizeof(struct set_assocsta_rsp);
regards,
dan carpenter
Powered by blists - more mailing lists