[PATCH] tty: n_gsm: return -EINVAL when adaption is not supported

Tom Rix posted 1 patch 4 years ago
drivers/tty/n_gsm.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] tty: n_gsm: return -EINVAL when adaption is not supported
Posted by Tom Rix 4 years ago
The clang build fails with
n_gsm.c:940:13: error: variable 'size' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        } else if (dlci->adaption == 2) {
                   ^~~~~~~~~~~~~~~~~~~

The else should return an error, so return -EINVAL.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/tty/n_gsm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index b0762d2fa8d6..3b8c65f66d64 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -944,6 +944,7 @@ static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci,
 	} else {
 		pr_err("%s: unsupported adaption %d\n", __func__,
 		       dlci->adaption);
+		return -EINVAL;
 	}
 
 	msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
-- 
2.27.0
Re: [PATCH] tty: n_gsm: return -EINVAL when adaption is not supported
Posted by Greg KH 4 years ago
On Tue, Apr 26, 2022 at 08:05:54AM -0400, Tom Rix wrote:
> The clang build fails with
> n_gsm.c:940:13: error: variable 'size' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>         } else if (dlci->adaption == 2) {
>                    ^~~~~~~~~~~~~~~~~~~
> 
> The else should return an error, so return -EINVAL.
> 
> Signed-off-by: Tom Rix <trix@redhat.com>

What commit id does this fix?  Any reason you didn't cc: the author of
the recent changes to this code?

Is this the same issue that 0-day reported?

thanks,

greg k-h
Re: [PATCH] tty: n_gsm: return -EINVAL when adaption is not supported
Posted by Tom Rix 4 years ago
On 4/26/22 5:12 AM, Greg KH wrote:
> On Tue, Apr 26, 2022 at 08:05:54AM -0400, Tom Rix wrote:
>> The clang build fails with
>> n_gsm.c:940:13: error: variable 'size' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>>          } else if (dlci->adaption == 2) {
>>                     ^~~~~~~~~~~~~~~~~~~
>>
>> The else should return an error, so return -EINVAL.
>>
>> Signed-off-by: Tom Rix <trix@redhat.com>
> What commit id does this fix?  Any reason you didn't cc: the author of
> the recent changes to this code?
Sorry missed this part.
> Is this the same issue that 0-day reported?

Maybe, it was part of next's update today.  Where is 0-day reported ?

Tom

>
> thanks,
>
> greg k-h
>

Re: [PATCH] tty: n_gsm: return -EINVAL when adaption is not supported
Posted by Greg KH 4 years ago
On Tue, Apr 26, 2022 at 11:16:35AM -0700, Tom Rix wrote:
> 
> On 4/26/22 5:12 AM, Greg KH wrote:
> > On Tue, Apr 26, 2022 at 08:05:54AM -0400, Tom Rix wrote:
> > > The clang build fails with
> > > n_gsm.c:940:13: error: variable 'size' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> > >          } else if (dlci->adaption == 2) {
> > >                     ^~~~~~~~~~~~~~~~~~~
> > > 
> > > The else should return an error, so return -EINVAL.
> > > 
> > > Signed-off-by: Tom Rix <trix@redhat.com>
> > What commit id does this fix?  Any reason you didn't cc: the author of
> > the recent changes to this code?
> Sorry missed this part.

Please always do that, otherwise it's hard to track, right?

> > Is this the same issue that 0-day reported?
> 
> Maybe, it was part of next's update today.  Where is 0-day reported ?

On the same mailing list you posted this patch to:
	https://lore.kernel.org/r/202204230704.5MxboEEo-lkp@intel.com

thanks,

greg k-h