UBI: Fix potential NULL-pointer dereference
Subsystems (2)
PATCH 1/1 UBI: Fix potential NULL-pointer dereference
It's no use to debug print a string before checking on NULL.
--- drivers/mtd/ubi/kapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/ubi/kapi.c +2 -2
@@ -242,11 +242,11 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,struct ubi_device *ubi;struct ubi_volume_desc *ret; -dbg_gen ("open device %d, volume %s, mode %d" , ubi_num, name, mode); -if (!name)return ERR_PTR (-EINVAL ); +dbg_gen ("open device %d, volume %s, mode %d" , ubi_num, name, mode); + len =strnlen (name,UBI_VOL_NAME_MAX +1 );if (len >UBI_VOL_NAME_MAX )return ERR_PTR (-EINVAL );
Signature · 1 line
1.9.1
Quoted 3 lines · Alexander Stein
It's no use to debug print a string before checking on NULL.
If the string is NULL, that could be very useful to know when debugging and the print function should handle that gracefully, i.e. by not printing anything for %s.
BR // Mats
Quoted 8 lines · Mats Kärrman
Quoted 3 lines · Alexander Stein
It's no use to debug print a string before checking on NULL.
If the string is NULL, that could be very useful to know when debugging and the print function should handle that gracefully, i.e. by not printing anything for %s.
%s will just result in (null), I do not see any issue with this.
Signature · 2 lines
Best Regards, Artem Bityutskiy
On Monday 31 March 2014, 12:46:40 wrote Artem Bityutskiy:
Quoted 11 lines · Mats Kärrman
Quoted 8 lines · Alexander Stein
Quoted 3 lines
It's no use to debug print a string before checking on NULL.
If the string is NULL, that could be very useful to know when debugging and the print function should handle that gracefully, i.e. by not printing anything for %s.
%s will just result in (null), I do not see any issue with this.
Oh, it does? I was not aware of that (kernel-specific) behavior. Sorry for ne noise.
Best regards,
Alexander