* [PATCH] blkmapd: fix coredump in bl_add_disk
@ 2021-12-01 8:21 lixiaokeng
2021-12-10 8:30 ` lixiaokeng
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: lixiaokeng @ 2021-12-01 8:21 UTC (permalink / raw)
To: steved, linux-nfs; +Cc: liuzhiqiang (I), linfeilong
The serial->data is not malloced separately (just part of
the serial), so it can't be freed. The bl_serial has its
own free function. Use it.
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
utils/blkmapd/device-discovery.c | 15 +++------------
utils/blkmapd/device-discovery.h | 2 ++
utils/blkmapd/device-inq.c | 4 ++--
3 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
index 2736ac89..cea33496 100644
--- a/utils/blkmapd/device-discovery.c
+++ b/utils/blkmapd/device-discovery.c
@@ -187,10 +187,7 @@ static void bl_add_disk(char *filepath)
}
if (disk && diskpath) {
- if (serial) {
- free(serial->data);
- free(serial);
- }
+ bl_free_scsi_string(serial);
return;
}
@@ -228,10 +225,7 @@ static void bl_add_disk(char *filepath)
disk->size = size;
disk->valid_path = path;
}
- if (serial) {
- free(serial->data);
- free(serial);
- }
+ bl_free_scsi_string(serial);
}
return;
@@ -241,10 +235,7 @@ static void bl_add_disk(char *filepath)
free(path->full_path);
free(path);
}
- if (serial) {
- free(serial->data);
- free(serial);
- }
+ bl_free_scsi_string(serial);
return;
}
diff --git a/utils/blkmapd/device-discovery.h b/utils/blkmapd/device-discovery.h
index a86eed99..462aa943 100644
--- a/utils/blkmapd/device-discovery.h
+++ b/utils/blkmapd/device-discovery.h
@@ -151,6 +151,8 @@ uint64_t process_deviceinfo(const char *dev_addr_buf,
extern ssize_t atomicio(ssize_t(*f) (int, void *, size_t),
int fd, void *_s, size_t n);
+extern struct bl_serial *bl_create_scsi_string(int len, const char *bytes);
+extern void bl_free_scsi_string(struct bl_serial *str);
extern struct bl_serial *bldev_read_serial(int fd, const char *filename);
extern enum bl_path_state_e bldev_read_ap_state(int fd);
extern int bl_discover_devices(void);
diff --git a/utils/blkmapd/device-inq.c b/utils/blkmapd/device-inq.c
index c7952c3e..9e5749ef 100644
--- a/utils/blkmapd/device-inq.c
+++ b/utils/blkmapd/device-inq.c
@@ -53,7 +53,7 @@
#define DEF_ALLOC_LEN 255
#define MX_ALLOC_LEN (0xc000 + 0x80)
-static struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
+struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
{
struct bl_serial *s;
@@ -66,7 +66,7 @@ static struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
return s;
}
-static void bl_free_scsi_string(struct bl_serial *str)
+void bl_free_scsi_string(struct bl_serial *str)
{
if (str)
free(str);
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] blkmapd: fix coredump in bl_add_disk
2021-12-01 8:21 [PATCH] blkmapd: fix coredump in bl_add_disk lixiaokeng
@ 2021-12-10 8:30 ` lixiaokeng
2022-03-11 8:24 ` lixiaokeng
2022-10-24 17:38 ` Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: lixiaokeng @ 2021-12-10 8:30 UTC (permalink / raw)
To: steved, linux-nfs; +Cc: liuzhiqiang (I), linfeilong
ping
On 2021/12/1 16:21, lixiaokeng wrote:
> The serial->data is not malloced separately (just part of
> the serial), so it can't be freed. The bl_serial has its
> own free function. Use it.
>
> Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> ---
> utils/blkmapd/device-discovery.c | 15 +++------------
> utils/blkmapd/device-discovery.h | 2 ++
> utils/blkmapd/device-inq.c | 4 ++--
> 3 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
> index 2736ac89..cea33496 100644
> --- a/utils/blkmapd/device-discovery.c
> +++ b/utils/blkmapd/device-discovery.c
> @@ -187,10 +187,7 @@ static void bl_add_disk(char *filepath)
> }
>
> if (disk && diskpath) {
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> return;
> }
>
> @@ -228,10 +225,7 @@ static void bl_add_disk(char *filepath)
> disk->size = size;
> disk->valid_path = path;
> }
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> }
> return;
>
> @@ -241,10 +235,7 @@ static void bl_add_disk(char *filepath)
> free(path->full_path);
> free(path);
> }
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> return;
> }
>
> diff --git a/utils/blkmapd/device-discovery.h b/utils/blkmapd/device-discovery.h
> index a86eed99..462aa943 100644
> --- a/utils/blkmapd/device-discovery.h
> +++ b/utils/blkmapd/device-discovery.h
> @@ -151,6 +151,8 @@ uint64_t process_deviceinfo(const char *dev_addr_buf,
>
> extern ssize_t atomicio(ssize_t(*f) (int, void *, size_t),
> int fd, void *_s, size_t n);
> +extern struct bl_serial *bl_create_scsi_string(int len, const char *bytes);
> +extern void bl_free_scsi_string(struct bl_serial *str);
> extern struct bl_serial *bldev_read_serial(int fd, const char *filename);
> extern enum bl_path_state_e bldev_read_ap_state(int fd);
> extern int bl_discover_devices(void);
> diff --git a/utils/blkmapd/device-inq.c b/utils/blkmapd/device-inq.c
> index c7952c3e..9e5749ef 100644
> --- a/utils/blkmapd/device-inq.c
> +++ b/utils/blkmapd/device-inq.c
> @@ -53,7 +53,7 @@
> #define DEF_ALLOC_LEN 255
> #define MX_ALLOC_LEN (0xc000 + 0x80)
>
> -static struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> +struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> {
> struct bl_serial *s;
>
> @@ -66,7 +66,7 @@ static struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> return s;
> }
>
> -static void bl_free_scsi_string(struct bl_serial *str)
> +void bl_free_scsi_string(struct bl_serial *str)
> {
> if (str)
> free(str);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] blkmapd: fix coredump in bl_add_disk
2021-12-01 8:21 [PATCH] blkmapd: fix coredump in bl_add_disk lixiaokeng
2021-12-10 8:30 ` lixiaokeng
@ 2022-03-11 8:24 ` lixiaokeng
2022-10-24 17:38 ` Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: lixiaokeng @ 2022-03-11 8:24 UTC (permalink / raw)
To: steved, linux-nfs; +Cc: liuzhiqiang (I), linfeilong
ping
On 2021/12/1 16:21, lixiaokeng wrote:
> The serial->data is not malloced separately (just part of
> the serial), so it can't be freed. The bl_serial has its
> own free function. Use it.
>
> Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> ---
> utils/blkmapd/device-discovery.c | 15 +++------------
> utils/blkmapd/device-discovery.h | 2 ++
> utils/blkmapd/device-inq.c | 4 ++--
> 3 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
> index 2736ac89..cea33496 100644
> --- a/utils/blkmapd/device-discovery.c
> +++ b/utils/blkmapd/device-discovery.c
> @@ -187,10 +187,7 @@ static void bl_add_disk(char *filepath)
> }
>
> if (disk && diskpath) {
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> return;
> }
>
> @@ -228,10 +225,7 @@ static void bl_add_disk(char *filepath)
> disk->size = size;
> disk->valid_path = path;
> }
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> }
> return;
>
> @@ -241,10 +235,7 @@ static void bl_add_disk(char *filepath)
> free(path->full_path);
> free(path);
> }
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> return;
> }
>
> diff --git a/utils/blkmapd/device-discovery.h b/utils/blkmapd/device-discovery.h
> index a86eed99..462aa943 100644
> --- a/utils/blkmapd/device-discovery.h
> +++ b/utils/blkmapd/device-discovery.h
> @@ -151,6 +151,8 @@ uint64_t process_deviceinfo(const char *dev_addr_buf,
>
> extern ssize_t atomicio(ssize_t(*f) (int, void *, size_t),
> int fd, void *_s, size_t n);
> +extern struct bl_serial *bl_create_scsi_string(int len, const char *bytes);
> +extern void bl_free_scsi_string(struct bl_serial *str);
> extern struct bl_serial *bldev_read_serial(int fd, const char *filename);
> extern enum bl_path_state_e bldev_read_ap_state(int fd);
> extern int bl_discover_devices(void);
> diff --git a/utils/blkmapd/device-inq.c b/utils/blkmapd/device-inq.c
> index c7952c3e..9e5749ef 100644
> --- a/utils/blkmapd/device-inq.c
> +++ b/utils/blkmapd/device-inq.c
> @@ -53,7 +53,7 @@
> #define DEF_ALLOC_LEN 255
> #define MX_ALLOC_LEN (0xc000 + 0x80)
>
> -static struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> +struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> {
> struct bl_serial *s;
>
> @@ -66,7 +66,7 @@ static struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> return s;
> }
>
> -static void bl_free_scsi_string(struct bl_serial *str)
> +void bl_free_scsi_string(struct bl_serial *str)
> {
> if (str)
> free(str);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] blkmapd: fix coredump in bl_add_disk
2021-12-01 8:21 [PATCH] blkmapd: fix coredump in bl_add_disk lixiaokeng
2021-12-10 8:30 ` lixiaokeng
2022-03-11 8:24 ` lixiaokeng
@ 2022-10-24 17:38 ` Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2022-10-24 17:38 UTC (permalink / raw)
To: lixiaokeng, linux-nfs; +Cc: liuzhiqiang (I), linfeilong
On 12/1/21 3:21 AM, lixiaokeng wrote:
> The serial->data is not malloced separately (just part of
> the serial), so it can't be freed. The bl_serial has its
> own free function. Use it.
>
> Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Committed...
steved.
> ---
> utils/blkmapd/device-discovery.c | 15 +++------------
> utils/blkmapd/device-discovery.h | 2 ++
> utils/blkmapd/device-inq.c | 4 ++--
> 3 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
> index 2736ac89..cea33496 100644
> --- a/utils/blkmapd/device-discovery.c
> +++ b/utils/blkmapd/device-discovery.c
> @@ -187,10 +187,7 @@ static void bl_add_disk(char *filepath)
> }
>
> if (disk && diskpath) {
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> return;
> }
>
> @@ -228,10 +225,7 @@ static void bl_add_disk(char *filepath)
> disk->size = size;
> disk->valid_path = path;
> }
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> }
> return;
>
> @@ -241,10 +235,7 @@ static void bl_add_disk(char *filepath)
> free(path->full_path);
> free(path);
> }
> - if (serial) {
> - free(serial->data);
> - free(serial);
> - }
> + bl_free_scsi_string(serial);
> return;
> }
>
> diff --git a/utils/blkmapd/device-discovery.h b/utils/blkmapd/device-discovery.h
> index a86eed99..462aa943 100644
> --- a/utils/blkmapd/device-discovery.h
> +++ b/utils/blkmapd/device-discovery.h
> @@ -151,6 +151,8 @@ uint64_t process_deviceinfo(const char *dev_addr_buf,
>
> extern ssize_t atomicio(ssize_t(*f) (int, void *, size_t),
> int fd, void *_s, size_t n);
> +extern struct bl_serial *bl_create_scsi_string(int len, const char *bytes);
> +extern void bl_free_scsi_string(struct bl_serial *str);
> extern struct bl_serial *bldev_read_serial(int fd, const char *filename);
> extern enum bl_path_state_e bldev_read_ap_state(int fd);
> extern int bl_discover_devices(void);
> diff --git a/utils/blkmapd/device-inq.c b/utils/blkmapd/device-inq.c
> index c7952c3e..9e5749ef 100644
> --- a/utils/blkmapd/device-inq.c
> +++ b/utils/blkmapd/device-inq.c
> @@ -53,7 +53,7 @@
> #define DEF_ALLOC_LEN 255
> #define MX_ALLOC_LEN (0xc000 + 0x80)
>
> -static struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> +struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> {
> struct bl_serial *s;
>
> @@ -66,7 +66,7 @@ static struct bl_serial *bl_create_scsi_string(int len, const char *bytes)
> return s;
> }
>
> -static void bl_free_scsi_string(struct bl_serial *str)
> +void bl_free_scsi_string(struct bl_serial *str)
> {
> if (str)
> free(str);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-24 20:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-01 8:21 [PATCH] blkmapd: fix coredump in bl_add_disk lixiaokeng
2021-12-10 8:30 ` lixiaokeng
2022-03-11 8:24 ` lixiaokeng
2022-10-24 17:38 ` Steve Dickson
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).