Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1302519 > unrolled thread

[patch] mtip32xx: calling kfree() on an error pointer

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-01-06 11:10 +0100
Last post2016-01-06 14:30 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [patch] mtip32xx: calling kfree() on an error pointer Dan Carpenter <dan.carpenter@oracle.com> - 2016-01-06 11:10 +0100
    Re: [patch] mtip32xx: calling kfree() on an error pointer Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-06 14:10 +0100
      Re: [patch] mtip32xx: calling kfree() on an error pointer Dan Carpenter <dan.carpenter@oracle.com> - 2016-01-06 14:20 +0100
        Re: [patch] mtip32xx: calling kfree() on an error pointer Al Viro <viro@ZenIV.linux.org.uk> - 2016-01-06 14:30 +0100

#1302519 — [patch] mtip32xx: calling kfree() on an error pointer

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-01-06 11:10 +0100
Subject[patch] mtip32xx: calling kfree() on an error pointer
Message-ID<qNTcu-87B-11@gated-at.bofh.it>
If memdup_user() fails then we end up passing an ERR_PTR to kfree()
which is a bug.

Fixes: 85b4d87c9962 ('mtip32xx: don't open-code memdup_user()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 618c24f..15bec40 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2032,6 +2032,7 @@ static int exec_drive_taskfile(struct driver_data *dd,
 		outbuf = memdup_user(buf + outtotal, taskout);
 		if (IS_ERR(outbuf)) {
 			err = PTR_ERR(outbuf);
+			outbuf = NULL;
 			goto abort;
 		}
 		outbuf_dma = pci_map_single(dd->pdev,
@@ -2049,6 +2050,7 @@ static int exec_drive_taskfile(struct driver_data *dd,
 		inbuf = memdup_user(buf + intotal, taskin);
 		if (IS_ERR(inbuf)) {
 			err = PTR_ERR(inbuf);
+			inbuf = NULL;
 			goto abort;
 		}
 		inbuf_dma = pci_map_single(dd->pdev,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1302741

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-06 14:10 +0100
Message-ID<qNW0H-1yG-47@gated-at.bofh.it>
In reply to#1302519
On Wed, Jan 06, 2016 at 01:05:03PM +0300, Dan Carpenter wrote:
> If memdup_user() fails then we end up passing an ERR_PTR to kfree()
> which is a bug.

Mind if I fold it (with credit, obviously)?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302752

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-01-06 14:20 +0100
Message-ID<qNWam-1Ck-25@gated-at.bofh.it>
In reply to#1302741
On Wed, Jan 06, 2016 at 01:08:00PM +0000, Al Viro wrote:
> On Wed, Jan 06, 2016 at 01:05:03PM +0300, Dan Carpenter wrote:
> > If memdup_user() fails then we end up passing an ERR_PTR to kfree()
> > which is a bug.
> 
> Mind if I fold it (with credit, obviously)?

No problem, that's fine.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302759

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-01-06 14:30 +0100
Message-ID<qNWk2-1HB-21@gated-at.bofh.it>
In reply to#1302752
On Wed, Jan 06, 2016 at 04:16:50PM +0300, Dan Carpenter wrote:
> On Wed, Jan 06, 2016 at 01:08:00PM +0000, Al Viro wrote:
> > On Wed, Jan 06, 2016 at 01:05:03PM +0300, Dan Carpenter wrote:
> > > If memdup_user() fails then we end up passing an ERR_PTR to kfree()
> > > which is a bug.
> > 
> > Mind if I fold it (with credit, obviously)?
> 
> No problem, that's fine.

Done.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web