From: Eric Dumazet <eric.dumazet@gmail.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu,
Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: ocelot_board: fix a NULL pointer dereference
Date: Mon, 11 Mar 2019 07:14:58 -0700 [thread overview]
Message-ID: <d61f3d5e-6f8c-5a44-447a-7fc96cb65037@gmail.com> (raw)
In-Reply-To: <20190311102600.GB1637@piout.net>
On 03/11/2019 03:26 AM, Alexandre Belloni wrote:
> On 11/03/2019 01:36:32-0500, Kangjie Lu wrote:
>> In case devm_kcalloc fails, the fix returns -ENOMEM to avoid
>> NULL pointer dereference.
>>
>> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
>
A proper error path is needed to avoid memory leaks.
>> ---
>> drivers/net/ethernet/mscc/ocelot_board.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
>> index e7f90101d2e0..af68abf1632a 100644
>> --- a/drivers/net/ethernet/mscc/ocelot_board.c
>> +++ b/drivers/net/ethernet/mscc/ocelot_board.c
>> @@ -256,6 +256,8 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
>>
>> ocelot->ports = devm_kcalloc(&pdev->dev, ocelot->num_phys_ports,
>> sizeof(struct ocelot_port *), GFP_KERNEL);
>> + if (!ocelot->ports)
>> + return -ENOMEM;
>>
>> INIT_LIST_HEAD(&ocelot->multicast);
>> ocelot_init(ocelot);
>> --
>> 2.17.1
>>
>
next prev parent reply other threads:[~2019-03-11 14:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-11 6:36 [PATCH] net: ocelot_board: fix a NULL pointer dereference Kangjie Lu
2019-03-11 10:26 ` Alexandre Belloni
2019-03-11 14:14 ` Eric Dumazet [this message]
2019-03-11 17:39 ` David Miller
2019-03-23 3:33 ` Kangjie Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d61f3d5e-6f8c-5a44-447a-7fc96cb65037@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=davem@davemloft.net \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pakki001@umn.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).