Messages in this thread | | | Date | Fri, 20 Sep 2013 13:43:43 +0300 | From | Dan Carpenter <> | Subject | Re: [PATCH 7/10] staging: r8188eu: Add files for new drive: Cocci spatch "noderef" |
| |
On Thu, Sep 19, 2013 at 11:45:46PM +0200, Thomas Meyer wrote: > sizeof when applied to a pointer typed expression gives the size of the > pointer. > Found by coccinelle spatch "misc/noderef.cocci" >
When you're writing the changelog for these it helps if you say how many bytes sizeof(*data) is. In this case, we have gone from clearing 8 bytes to clearing 1 byte so the original code had a potential memory corruption bug.
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de> > --- > > diff -u -p a/drivers/staging/rtl8188eu/core/rtw_mp.c b/drivers/staging/rtl8188eu/core/rtw_mp.c > --- a/drivers/staging/rtl8188eu/core/rtw_mp.c > +++ b/drivers/staging/rtl8188eu/core/rtw_mp.c > @@ -907,7 +907,7 @@ u32 mp_query_psd(struct adapter *pAdapte > sscanf(data, "pts =%d, start =%d, stop =%d", &psd_pts, &psd_start, &psd_stop); > } > > - _rtw_memset(data, '\0', sizeof(data)); > + _rtw_memset(data, '\0', sizeof(*data));
I think your fix is correct but it would be better to remove the memset and do:
data[0] = '\0';
"data" is a u8 pointer, but it should obviously be a char pointer. The original code here is not high quality. :P
regards, dan carpenter
| |