linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192e: fix array of flexible structures
@ 2021-04-27 17:49 Jitendra Khasdev
  2021-04-27 18:10 ` Greg KH
  2021-04-29 14:20 ` Dan Carpenter
  0 siblings, 2 replies; 6+ messages in thread
From: Jitendra Khasdev @ 2021-04-27 17:49 UTC (permalink / raw)
  To: gregkh, devel, linux-kernel; +Cc: jkhasdev

This patch fixes sparse warning "array of flexible structures"
for rtllib.h.

eg. drivers/staging/rtl8192e/rtllib.h:832:48: warning: array of
flexible structures

Signed-off-by: Jitendra Khasdev <jkhasdev@gmail.com>
---
 drivers/staging/rtl8192e/rtllib.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index 4cabaf2..c7cb318 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -802,7 +802,7 @@ struct rtllib_authentication {
 	__le16 transaction;
 	__le16 status;
 	/*challenge*/
-	struct rtllib_info_element info_element[];
+	struct rtllib_info_element *info_element;
 } __packed;
 
 struct rtllib_disauth {
@@ -818,7 +818,7 @@ struct rtllib_disassoc {
 struct rtllib_probe_request {
 	struct rtllib_hdr_3addr header;
 	/* SSID, supported rates */
-	struct rtllib_info_element info_element[];
+	struct rtllib_info_element *info_element;
 } __packed;
 
 struct rtllib_probe_response {
@@ -829,7 +829,7 @@ struct rtllib_probe_response {
 	/* SSID, supported rates, FH params, DS params,
 	 * CF params, IBSS params, TIM (if beacon), RSN
 	 */
-	struct rtllib_info_element info_element[];
+	struct rtllib_info_element *info_element;
 } __packed;
 
 /* Alias beacon for probe_response */
@@ -840,7 +840,7 @@ struct rtllib_assoc_request_frame {
 	__le16 capability;
 	__le16 listen_interval;
 	/* SSID, supported rates, RSN */
-	struct rtllib_info_element info_element[];
+	struct rtllib_info_element *info_element;
 } __packed;
 
 struct rtllib_assoc_response_frame {
@@ -848,7 +848,7 @@ struct rtllib_assoc_response_frame {
 	__le16 capability;
 	__le16 status;
 	__le16 aid;
-	struct rtllib_info_element info_element[]; /* supported rates */
+	struct rtllib_info_element *info_element; /* supported rates */
 } __packed;
 
 struct rtllib_txb {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: rtl8192e: fix array of flexible structures
  2021-04-27 17:49 [PATCH] staging: rtl8192e: fix array of flexible structures Jitendra Khasdev
@ 2021-04-27 18:10 ` Greg KH
  2021-04-27 18:58   ` Jitendra
  2021-04-29 14:20 ` Dan Carpenter
  1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2021-04-27 18:10 UTC (permalink / raw)
  To: Jitendra Khasdev; +Cc: devel, linux-kernel

On Tue, Apr 27, 2021 at 11:19:45PM +0530, Jitendra Khasdev wrote:
> This patch fixes sparse warning "array of flexible structures"
> for rtllib.h.
> 
> eg. drivers/staging/rtl8192e/rtllib.h:832:48: warning: array of
> flexible structures
> 
> Signed-off-by: Jitendra Khasdev <jkhasdev@gmail.com>
> ---
>  drivers/staging/rtl8192e/rtllib.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
> index 4cabaf2..c7cb318 100644
> --- a/drivers/staging/rtl8192e/rtllib.h
> +++ b/drivers/staging/rtl8192e/rtllib.h
> @@ -802,7 +802,7 @@ struct rtllib_authentication {
>  	__le16 transaction;
>  	__le16 status;
>  	/*challenge*/
> -	struct rtllib_info_element info_element[];
> +	struct rtllib_info_element *info_element;

You just changed the definition of this structure, and the other
structures here.  Are you sure this is working properly?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: rtl8192e: fix array of flexible structures
  2021-04-27 18:10 ` Greg KH
@ 2021-04-27 18:58   ` Jitendra
  2021-04-28  6:01     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Jitendra @ 2021-04-27 18:58 UTC (permalink / raw)
  To: Greg KH; +Cc: devel, linux-kernel

On Tue, Apr 27, 2021 at 08:10:20PM +0200, Greg KH wrote:
>On Tue, Apr 27, 2021 at 11:19:45PM +0530, Jitendra Khasdev wrote:
>> This patch fixes sparse warning "array of flexible structures"
>> for rtllib.h.
>>
>> eg. drivers/staging/rtl8192e/rtllib.h:832:48: warning: array of
>> flexible structures
>>
>> Signed-off-by: Jitendra Khasdev <jkhasdev@gmail.com>
>> ---
>>  drivers/staging/rtl8192e/rtllib.h | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
>> index 4cabaf2..c7cb318 100644
>> --- a/drivers/staging/rtl8192e/rtllib.h
>> +++ b/drivers/staging/rtl8192e/rtllib.h
>> @@ -802,7 +802,7 @@ struct rtllib_authentication {
>>  	__le16 transaction;
>>  	__le16 status;
>>  	/*challenge*/
>> -	struct rtllib_info_element info_element[];
>> +	struct rtllib_info_element *info_element;
>
>You just changed the definition of this structure, and the other
>structures here.  Are you sure this is working properly?
>

I have compiled the driver and install it on my vm, but I don't this specific
hardware, so couldn't test it.

I fixed in context of sparse.

---
Jitendra

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: rtl8192e: fix array of flexible structures
  2021-04-27 18:58   ` Jitendra
@ 2021-04-28  6:01     ` Greg KH
  2021-04-28  7:24       ` Jitendra
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2021-04-28  6:01 UTC (permalink / raw)
  To: Jitendra; +Cc: devel, linux-kernel

On Wed, Apr 28, 2021 at 12:28:44AM +0530, Jitendra wrote:
> On Tue, Apr 27, 2021 at 08:10:20PM +0200, Greg KH wrote:
> > On Tue, Apr 27, 2021 at 11:19:45PM +0530, Jitendra Khasdev wrote:
> > > This patch fixes sparse warning "array of flexible structures"
> > > for rtllib.h.
> > > 
> > > eg. drivers/staging/rtl8192e/rtllib.h:832:48: warning: array of
> > > flexible structures
> > > 
> > > Signed-off-by: Jitendra Khasdev <jkhasdev@gmail.com>
> > > ---
> > >  drivers/staging/rtl8192e/rtllib.h | 10 +++++-----
> > >  1 file changed, 5 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
> > > index 4cabaf2..c7cb318 100644
> > > --- a/drivers/staging/rtl8192e/rtllib.h
> > > +++ b/drivers/staging/rtl8192e/rtllib.h
> > > @@ -802,7 +802,7 @@ struct rtllib_authentication {
> > >  	__le16 transaction;
> > >  	__le16 status;
> > >  	/*challenge*/
> > > -	struct rtllib_info_element info_element[];
> > > +	struct rtllib_info_element *info_element;
> > 
> > You just changed the definition of this structure, and the other
> > structures here.  Are you sure this is working properly?
> > 
> 
> I have compiled the driver and install it on my vm, but I don't this specific
> hardware, so couldn't test it.
> 
> I fixed in context of sparse.

Please verify that this change is correct by looking at how the
structures are being created (i.e. is this being treated as a flexible
array or a pointer?)

I think we have been through this before and that sparse is not right,
but I can't remember...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: rtl8192e: fix array of flexible structures
  2021-04-28  6:01     ` Greg KH
@ 2021-04-28  7:24       ` Jitendra
  0 siblings, 0 replies; 6+ messages in thread
From: Jitendra @ 2021-04-28  7:24 UTC (permalink / raw)
  To: Greg KH; +Cc: devel, linux-kernel

On Wed, Apr 28, 2021 at 08:01:21AM +0200, Greg KH wrote:
>On Wed, Apr 28, 2021 at 12:28:44AM +0530, Jitendra wrote:
>> On Tue, Apr 27, 2021 at 08:10:20PM +0200, Greg KH wrote:
>> > On Tue, Apr 27, 2021 at 11:19:45PM +0530, Jitendra Khasdev wrote:
>> > > This patch fixes sparse warning "array of flexible structures"
>> > > for rtllib.h.
>> > >
>> > > eg. drivers/staging/rtl8192e/rtllib.h:832:48: warning: array of
>> > > flexible structures
>> > >
>> > > Signed-off-by: Jitendra Khasdev <jkhasdev@gmail.com>
>> > > ---
>> > >  drivers/staging/rtl8192e/rtllib.h | 10 +++++-----
>> > >  1 file changed, 5 insertions(+), 5 deletions(-)
>> > >
>> > > diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
>> > > index 4cabaf2..c7cb318 100644
>> > > --- a/drivers/staging/rtl8192e/rtllib.h
>> > > +++ b/drivers/staging/rtl8192e/rtllib.h
>> > > @@ -802,7 +802,7 @@ struct rtllib_authentication {
>> > >  	__le16 transaction;
>> > >  	__le16 status;
>> > >  	/*challenge*/
>> > > -	struct rtllib_info_element info_element[];
>> > > +	struct rtllib_info_element *info_element;
>> >
>> > You just changed the definition of this structure, and the other
>> > structures here.  Are you sure this is working properly?
>> >
>>
>> I have compiled the driver and install it on my vm, but I don't this specific
>> hardware, so couldn't test it.
>>
>> I fixed in context of sparse.
>
>Please verify that this change is correct by looking at how the
>structures are being created (i.e. is this being treated as a flexible
>array or a pointer?)
>
>I think we have been through this before and that sparse is not right,
>but I can't remember...
>
Yes, it is getting used as flexible array in code. hence, simply we can drop
this patch.

Also, looks to me, there is no more sparse warnings to fix in staging.

---
Jitendra

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: rtl8192e: fix array of flexible structures
  2021-04-27 17:49 [PATCH] staging: rtl8192e: fix array of flexible structures Jitendra Khasdev
  2021-04-27 18:10 ` Greg KH
@ 2021-04-29 14:20 ` Dan Carpenter
  1 sibling, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2021-04-29 14:20 UTC (permalink / raw)
  To: Jitendra Khasdev; +Cc: gregkh, devel, linux-kernel

On Tue, Apr 27, 2021 at 11:19:45PM +0530, Jitendra Khasdev wrote:
> This patch fixes sparse warning "array of flexible structures"
> for rtllib.h.
> 
> eg. drivers/staging/rtl8192e/rtllib.h:832:48: warning: array of
> flexible structures
> 
> Signed-off-by: Jitendra Khasdev <jkhasdev@gmail.com>
> ---
>  drivers/staging/rtl8192e/rtllib.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
> index 4cabaf2..c7cb318 100644
> --- a/drivers/staging/rtl8192e/rtllib.h
> +++ b/drivers/staging/rtl8192e/rtllib.h
> @@ -802,7 +802,7 @@ struct rtllib_authentication {
>  	__le16 transaction;
>  	__le16 status;
>  	/*challenge*/
> -	struct rtllib_info_element info_element[];
> +	struct rtllib_info_element *info_element;
>  } __packed;

This patch is wrong.

The original code is basically fine.  Normally it doesn't make sense to
have an array of flex arrays, but in this case it "flexes" between 0 and
1.  If it were had two elements then the match the math wouldn't work
at all.

We should probably get rid of it and just add some giant comments and
defines to do the math.

But changing it to a pointer isn't right.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-29 14:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 17:49 [PATCH] staging: rtl8192e: fix array of flexible structures Jitendra Khasdev
2021-04-27 18:10 ` Greg KH
2021-04-27 18:58   ` Jitendra
2021-04-28  6:01     ` Greg KH
2021-04-28  7:24       ` Jitendra
2021-04-29 14:20 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).