From: "Björn Fahller" <bjorn@netinsight.se>
To: Oleg Drokin <green@linuxhacker.ru>,
alan@redhat.com, linux-kernel@vger.kernel.org,
zubarev@us.ibm.com
Subject: Re: [2.4] Multiple memleaks in IBM Hot Plug Controller Driver
Date: Fri, 14 Mar 2003 09:34:44 +0100 [thread overview]
Message-ID: <200303140934.44245.bjorn@netinsight.se> (raw)
In-Reply-To: <20030313204556.GA3475@linuxhacker.ru>
On Thursday 13 March 2003 21.45, Oleg Drokin wrote:
Below, why allocating 2 bytes on heap (str1,) only to non-conditionally free
it a few lines further down? Why not keep the two bytes on stack instead? It
also seems like a bad idea to strncopy/strcat 1 byte long strings.
_
/Bjorn.
> ===== drivers/hotplug/ibmphp_ebda.c 1.6 vs edited =====
> --- 1.6/drivers/hotplug/ibmphp_ebda.c Fri Sep 13 21:56:25 2002
> +++ edited/drivers/hotplug/ibmphp_ebda.c Thu Mar 13 23:40:29 2003
> @@ -608,13 +608,20 @@
> return str;
> default:
> //2 digits number
> + str1 = (char *) kmalloc (2, GFP_KERNEL);
> + if (!str1) {
> + break;
> + }
> + memset (str, 0, 3);
> *str1 = (char)(bit + 48);
> strncpy (str, str1, 1);
> memset (str1, 0, 3);
> *str1 = (char)((var % 10) + 48);
> strcat (str, str1);
> + kfree(str1);
> return str;
> - }
> + }
> + kfree(str);
> return NULL;
> }
>
> @@ -1022,6 +1029,10 @@
> bus_info_ptr1 = ibmphp_find_same_bus_num
> (hpc_ptr->slots[index].slot_bus_num); if (!bus_info_ptr1) {
> iounmap (io_mem);
> + kfree (hp_slot_ptr->name);
> + kfree (hp_slot_ptr->info);
> + kfree (hp_slot_ptr->private);
> + kfree (hp_slot_ptr);
> return -ENODEV;
> }
> ((struct slot *) hp_slot_ptr->private)->bus_on = bus_info_ptr1;
> @@ -1036,12 +1047,20 @@
> rc = ibmphp_hpc_fillhpslotinfo (hp_slot_ptr);
> if (rc) {
> iounmap (io_mem);
> + kfree (hp_slot_ptr->name);
> + kfree (hp_slot_ptr->info);
> + kfree (hp_slot_ptr->private);
> + kfree (hp_slot_ptr);
> return rc;
> }
>
> rc = ibmphp_init_devno ((struct slot **) &hp_slot_ptr->private);
> if (rc) {
> iounmap (io_mem);
> + kfree (hp_slot_ptr->name);
> + kfree (hp_slot_ptr->info);
> + kfree (hp_slot_ptr->private);
> + kfree (hp_slot_ptr);
> return rc;
> }
> hp_slot_ptr->ops = &ibmphp_hotplug_slot_ops;
> -
> 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/
next prev parent reply other threads:[~2003-03-14 8:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-13 20:45 Oleg Drokin
2003-03-14 0:31 ` Greg KH
2003-03-14 20:14 ` Oleg Drokin
2003-03-14 8:34 ` Björn Fahller [this message]
2003-03-14 8:57 ` Greg KH
2003-03-14 9:54 ` Denis Vlasenko
2003-03-14 10:26 ` Oleg Drokin
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=200303140934.44245.bjorn@netinsight.se \
--to=bjorn@netinsight.se \
--cc=alan@redhat.com \
--cc=green@linuxhacker.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=zubarev@us.ibm.com \
/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
all inboxes | Powered by JetHome®