lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 13 Sep 2016 10:36:36 +0200
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     Ilya Dryomov <idryomov@...il.com>
Cc:     ceph-devel@...r.kernel.org, Alex Elder <elder@...nel.org>,
        Sage Weil <sage@...hat.com>,
        LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org,
        Julia Lawall <julia.lawall@...6.fr>
Subject: Re: [PATCH 04/47] block-rbd: Refactor two calls for memory
 allocations in rbd_dev_image_id()

>> @@ -5833,7 +5833,6 @@ again:
>>  static int rbd_dev_image_id(struct rbd_device *rbd_dev)
>>  {
>>         int ret;
>> -       size_t size;
>>         char *object_name;
>>         void *response;
>>         char *image_id;
>> @@ -5854,17 +5853,16 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev)
>>          * First, see if the format 2 image id file exists, and if
>>          * so, get the image's persistent id from it.
>>          */
>> -       size = sizeof (RBD_ID_PREFIX) + strlen(rbd_dev->spec->image_name);
>> -       object_name = kmalloc(size, GFP_NOIO);
>> +       object_name = kmalloc(sizeof(RBD_ID_PREFIX)
>> +                             + strlen(rbd_dev->spec->image_name),
>> +                             GFP_NOIO);
>>         if (!object_name)
>>                 return -ENOMEM;
>>         sprintf(object_name, "%s%s", RBD_ID_PREFIX, rbd_dev->spec->image_name);
>>         dout("rbd id object name is %s\n", object_name);
>>
>>         /* Response will be an encoded string, which includes a length */
>> -
>> -       size = sizeof (__le32) + RBD_IMAGE_ID_LEN_MAX;
>> -       response = kzalloc(size, GFP_NOIO);
>> +       response = kzalloc(sizeof(__le32) + RBD_IMAGE_ID_LEN_MAX, GFP_NOIO);
>>         if (!response) {
>>                 ret = -ENOMEM;
>>                 goto out;
…
> How is this any better?

I find it useful to omit the local variable "size" here.


> If anything, it makes the first kmalloc() call slightly less readable.

I got an other impression. The refactored function call did not fit into a single line
because of a well-known length limitation.

Does the kzalloc() call look a bit nicer for you now?

Regards,
Markus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ