diff --git a/block/blktrace.c b/block/blktrace.c
index 9e0212c90b29eb0c3d1fd29e0aed9affdc4aa1e4..85049a7e7a179a97c283eb4ebe6c1fe7285f80cf 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -369,7 +369,8 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
 	if (!buts->buf_size || !buts->buf_nr)
 		return -EINVAL;
 
-	strcpy(buts->name, name);
+	strncpy(buts->name, name, BLKTRACE_BDEV_SIZE);
+	buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0';
 
 	/*
 	 * some device names have larger paths - convert the slashes
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index a2a7d0ca27587d007baef289589566e374fb72ec..3a31eb506164a814a2b9599d11d709f9915ed1cc 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -122,15 +122,13 @@ enum {
 	Blktrace_stopped,
 };
 
+#define BLKTRACE_BDEV_SIZE	32
+
 /*
  * User setup structure passed with BLKTRACESTART
  */
 struct blk_user_trace_setup {
-#ifdef __KERNEL__
-	char name[BDEVNAME_SIZE];	/* output */
-#else
-	char name[32];			/* output */
-#endif
+	char name[BLKTRACE_BDEV_SIZE];	/* output */
 	__u16 act_mask;			/* input */
 	__u32 buf_size;			/* input */
 	__u32 buf_nr;			/* input */