diff mbox series

um: vector: Avoid NULL ptr deference if transport is unset

Message ID 20200216213624.800463-1-sjoerd.simons@collabora.co.uk
State Accepted
Headers show
Series um: vector: Avoid NULL ptr deference if transport is unset | expand

Commit Message

Sjoerd Simons Feb. 16, 2020, 9:36 p.m. UTC
When the transport option of a vec isn't set strncmp ends up being
called on a NULL pointer. Better not do that.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

---

 arch/um/drivers/vector_kern.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Anton Ivanov Feb. 17, 2020, 7:53 a.m. UTC | #1
On 16/02/2020 21:36, Sjoerd Simons wrote:
> When the transport option of a vec isn't set strncmp ends up being
> called on a NULL pointer. Better not do that.
> 
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> 
> ---
> 
>   arch/um/drivers/vector_kern.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 0ff86391f77d..ca90666c0b61 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -198,6 +198,9 @@ static int get_transport_options(struct arglist *def)
>   	long parsed;
>   	int result = 0;
>   
> +	if (transport == NULL)
> +		return -EINVAL;
> +
>   	if (vector != NULL) {
>   		if (kstrtoul(vector, 10, &parsed) == 0) {
>   			if (parsed == 0) {
> 
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Richard Weinberger March 29, 2020, 9:55 p.m. UTC | #2
On Mon, Feb 17, 2020 at 8:54 AM Anton Ivanov
<anton.ivanov@cambridgegreys.com> wrote:
>
> On 16/02/2020 21:36, Sjoerd Simons wrote:
> > When the transport option of a vec isn't set strncmp ends up being
> > called on a NULL pointer. Better not do that.
> >
> > Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> >
> > ---
> >
> >   arch/um/drivers/vector_kern.c | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> > index 0ff86391f77d..ca90666c0b61 100644
> > --- a/arch/um/drivers/vector_kern.c
> > +++ b/arch/um/drivers/vector_kern.c
> > @@ -198,6 +198,9 @@ static int get_transport_options(struct arglist *def)
> >       long parsed;
> >       int result = 0;
> >
> > +     if (transport == NULL)
> > +             return -EINVAL;
> > +
> >       if (vector != NULL) {
> >               if (kstrtoul(vector, 10, &parsed) == 0) {
> >                       if (parsed == 0) {
> >
> Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 0ff86391f77d..ca90666c0b61 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -198,6 +198,9 @@  static int get_transport_options(struct arglist *def)
 	long parsed;
 	int result = 0;
 
+	if (transport == NULL)
+		return -EINVAL;
+
 	if (vector != NULL) {
 		if (kstrtoul(vector, 10, &parsed) == 0) {
 			if (parsed == 0) {