linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] cosa: Add missing kfree in error path of cosa_write
@ 2020-11-10 14:46 Wang Hai
  2020-11-10 16:38 ` Jan Kasprzak
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Hai @ 2020-11-10 14:46 UTC (permalink / raw)
  To: davem, kas, kuba; +Cc: netdev, linux-kernel

If memory allocation for 'kbuf' succeed, cosa_write() doesn't have a
corresponding kfree() in exception handling. Thus add kfree() for this
function implementation.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
 drivers/net/wan/cosa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index f8aed0696d77..2369ca250cd6 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -889,6 +889,7 @@ static ssize_t cosa_write(struct file *file,
 			chan->tx_status = 1;
 			spin_unlock_irqrestore(&cosa->lock, flags);
 			up(&chan->wsem);
+			kfree(kbuf);
 			return -ERESTARTSYS;
 		}
 	}
-- 
2.17.1


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

* Re: [PATCH net] cosa: Add missing kfree in error path of cosa_write
  2020-11-10 14:46 [PATCH net] cosa: Add missing kfree in error path of cosa_write Wang Hai
@ 2020-11-10 16:38 ` Jan Kasprzak
  2020-11-12  2:03   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kasprzak @ 2020-11-10 16:38 UTC (permalink / raw)
  To: Wang Hai; +Cc: davem, kuba, netdev, linux-kernel

Wang Hai wrote:
: If memory allocation for 'kbuf' succeed, cosa_write() doesn't have a
: corresponding kfree() in exception handling. Thus add kfree() for this
: function implementation.

Acked-By: Jan "Yenya" Kasprzak <kas@fi.muni.cz>

Looks correct, thanks.

That said, COSA is an ancient ISA bus device designed in late 1990s,
I doubt anybody is still using it. I still do have one or two of these
cards myself, but no computer with ISA bus to use them.

-Yenya

: 
: Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
: Reported-by: Hulk Robot <hulkci@huawei.com>
: Signed-off-by: Wang Hai <wanghai38@huawei.com>
: ---
:  drivers/net/wan/cosa.c | 1 +
:  1 file changed, 1 insertion(+)
: 
: diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
: index f8aed0696d77..2369ca250cd6 100644
: --- a/drivers/net/wan/cosa.c
: +++ b/drivers/net/wan/cosa.c
: @@ -889,6 +889,7 @@ static ssize_t cosa_write(struct file *file,
:  			chan->tx_status = 1;
:  			spin_unlock_irqrestore(&cosa->lock, flags);
:  			up(&chan->wsem);
: +			kfree(kbuf);
:  			return -ERESTARTSYS;
:  		}
:  	}
: -- 
: 2.17.1

-- 
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| http://www.fi.muni.cz/~kas/                         GPG: 4096R/A45477D5 |
    We all agree on the necessity of compromise. We just can't agree on
    when it's necessary to compromise.                     --Larry Wall

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

* Re: [PATCH net] cosa: Add missing kfree in error path of cosa_write
  2020-11-10 16:38 ` Jan Kasprzak
@ 2020-11-12  2:03   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2020-11-12  2:03 UTC (permalink / raw)
  To: Jan Kasprzak; +Cc: Wang Hai, davem, netdev, linux-kernel

On Tue, 10 Nov 2020 17:38:09 +0100 Jan Kasprzak wrote:
> Wang Hai wrote:
> : If memory allocation for 'kbuf' succeed, cosa_write() doesn't have a
> : corresponding kfree() in exception handling. Thus add kfree() for this
> : function implementation.
> 
> Acked-By: Jan "Yenya" Kasprzak <kas@fi.muni.cz>

Applied, thanks!

> That said, COSA is an ancient ISA bus device designed in late 1990s,
> I doubt anybody is still using it. I still do have one or two of these
> cards myself, but no computer with ISA bus to use them.

Maybe we can move it out to staging or just remove it?

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

end of thread, other threads:[~2020-11-12  5:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 14:46 [PATCH net] cosa: Add missing kfree in error path of cosa_write Wang Hai
2020-11-10 16:38 ` Jan Kasprzak
2020-11-12  2:03   ` Jakub Kicinski

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).